Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
StringBuilderExtensions.cs
Go to the documentation of this file.
1using System.Text;
2
3namespace System.Net.Http;
4
5internal static class StringBuilderExtensions
6{
7 private static readonly char[] SpecialCharacters = new char[2] { '"', '\\' };
8
9 public static void AppendKeyValue(this StringBuilder sb, string key, string value, bool includeQuotes = true, bool includeComma = true)
10 {
11 sb.Append(key);
12 sb.Append('=');
13 if (includeQuotes)
14 {
15 sb.Append('"');
16 int num = 0;
17 while (true)
18 {
19 int num2 = value.IndexOfAny(SpecialCharacters, num);
20 if (num2 < 0)
21 {
22 break;
23 }
24 sb.Append(value, num, num2 - num);
25 sb.Append('\\');
26 sb.Append(value[num2]);
27 num = num2 + 1;
28 }
29 sb.Append(value, num, value.Length - num);
30 sb.Append('"');
31 }
32 else
33 {
34 sb.Append(value);
35 }
36 if (includeComma)
37 {
38 sb.Append(',');
39 sb.Append(' ');
40 }
41 }
42}
static void AppendKeyValue(this StringBuilder sb, string key, string value, bool includeQuotes=true, bool includeComma=true)
StringBuilder Append(char value, int repeatCount)