Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Utf16StringValidator.cs
Go to the documentation of this file.
1namespace System.Web.Util;
2
3internal static class Utf16StringValidator
4{
5 internal static string ValidateString(string input)
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 }
48}
static string ValidateString(string input)