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

◆ CompareStringIgnoreCase()

static int System.Globalization.OrdinalCasing.CompareStringIgnoreCase ( ref char strA,
int lengthA,
ref char strB,
int lengthB )
inlinestaticpackage

Definition at line 97 of file OrdinalCasing.cs.

98 {
99 int num = Math.Min(lengthA, lengthB);
100 ref char reference = ref strA;
101 ref char reference2 = ref strB;
102 int num2 = 0;
103 while (num2 < num)
104 {
105 char c = reference;
106 char c2 = reference2;
107 char c3 = '\0';
108 if (!char.IsHighSurrogate(c) || num2 >= lengthA - 1 || !char.IsLowSurrogate(c3 = Unsafe.Add(ref reference, 1)))
109 {
110 if (!char.IsHighSurrogate(c2) || num2 >= lengthB - 1 || !char.IsLowSurrogate(Unsafe.Add(ref reference2, 1)))
111 {
112 if (c2 == c)
113 {
114 num2++;
115 reference = ref Unsafe.Add(ref reference, 1);
116 reference2 = ref Unsafe.Add(ref reference2, 1);
117 continue;
118 }
119 char c4 = ToUpper(c);
120 char c5 = ToUpper(c2);
121 if (c4 == c5)
122 {
123 num2++;
124 reference = ref Unsafe.Add(ref reference, 1);
125 reference2 = ref Unsafe.Add(ref reference2, 1);
126 continue;
127 }
128 return c - c2;
129 }
130 return -1;
131 }
132 char c6 = '\0';
133 if (!char.IsHighSurrogate(c2) || num2 >= lengthB - 1 || !char.IsLowSurrogate(c6 = Unsafe.Add(ref reference2, 1)))
134 {
135 return 1;
136 }
137 if (c == c2 && c3 == c6)
138 {
139 num2 += 2;
140 reference = ref Unsafe.Add(ref reference, 2);
141 reference2 = ref Unsafe.Add(ref reference2, 2);
142 continue;
143 }
144 uint num3 = CharUnicodeInfo.ToUpper(UnicodeUtility.GetScalarFromUtf16SurrogatePair(c, c3));
145 uint num4 = CharUnicodeInfo.ToUpper(UnicodeUtility.GetScalarFromUtf16SurrogatePair(c2, c6));
146 if (num3 == num4)
147 {
148 num2 += 2;
149 reference = ref Unsafe.Add(ref reference, 2);
150 reference2 = ref Unsafe.Add(ref reference2, 2);
151 continue;
152 }
153 return (int)(num3 - num4);
154 }
155 return lengthA - lengthB;
156 }
static uint GetScalarFromUtf16SurrogatePair(uint highSurrogateCodePoint, uint lowSurrogateCodePoint)

References System.Text.UnicodeUtility.GetScalarFromUtf16SurrogatePair(), System.Math.Min(), System.Globalization.OrdinalCasing.ToUpper(), and System.Globalization.CharUnicodeInfo.ToUpper().

Referenced by System.Globalization.Ordinal.CompareStringIgnoreCaseNonAscii().