Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ValidateString()

static string System.Web.Util.Utf16StringValidator.ValidateString ( string input)
inlinestaticpackage

Definition at line 5 of file Utf16StringValidator.cs.

6 {
7 if (string.IsNullOrEmpty(input))
8 {
9 return input;
10 }
11 int num = -1;
12 for (int i = 0; i < input.Length; i++)
13 {
14 if (char.IsSurrogate(input[i]))
15 {
16 num = i;
17 break;
18 }
19 }
20 if (num < 0)
21 {
22 return input;
23 }
24 return string.Create(input.Length, (input, num), delegate(Span<char> chars, (string input, int idxOfFirstSurrogate) state)
25 {
26 state.input.CopyTo(chars);
27 for (int j = state.idxOfFirstSurrogate; j < chars.Length; j++)
28 {
29 char c = chars[j];
30 if (char.IsLowSurrogate(c))
31 {
32 chars[j] = '\ufffd';
33 }
34 else if (char.IsHighSurrogate(c))
35 {
36 if (j + 1 < chars.Length && char.IsLowSurrogate(chars[j + 1]))
37 {
38 j++;
39 }
40 else
41 {
42 chars[j] = '\ufffd';
43 }
44 }
45 }
46 });
47 }

References System.chars, System.input, and System.state.

Referenced by System.Web.Util.HttpEncoder.UrlDecode(), and System.Web.Util.HttpEncoder.UrlDecode().