Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CompareInfo.cs
Go to the documentation of this file.
10using System.Text;
11
12namespace System.Globalization;
13
15[TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
17{
18 private static class SortHandleCache
19 {
21
22 internal static IntPtr GetCachedSortHandle(string sortName)
23 {
25 {
27 {
29 {
30 case Interop.Globalization.ResultCode.OutOfMemory:
31 throw new OutOfMemoryException();
32 default:
34 case Interop.Globalization.ResultCode.Success:
35 break;
36 }
37 try
38 {
40 }
41 catch
42 {
44 throw;
45 }
46 }
47 return value;
48 }
49 }
50 }
51
52 internal static readonly CompareInfo Invariant = CultureInfo.InvariantCulture.CompareInfo;
53
54 [OptionalField(VersionAdded = 2)]
55 private string m_name;
56
59
61 private string _sortName;
62
63 [OptionalField(VersionAdded = 3)]
65
66 private int culture;
67
70
71 public string Name
72 {
73 get
74 {
75 if (m_name == "zh-CHT" || m_name == "zh-CHS")
76 {
77 return m_name;
78 }
79 return _sortName;
80 }
81 }
82
84 {
85 get
86 {
87 if (m_SortVersion == null)
88 {
90 {
91 m_SortVersion = new SortVersion(0, 127, new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127));
92 }
93 else
94 {
96 }
97 }
98 return m_SortVersion;
99 }
100 }
101
102 public int LCID => CultureInfo.GetCultureInfo(Name).LCID;
103
104 private static ReadOnlySpan<bool> HighCharTable => new bool[128]
105 {
106 true, true, true, true, true, true, true, true, true, false,
107 true, false, false, true, true, true, true, true, true, true,
108 true, true, true, true, true, true, true, true, true, true,
109 true, true, false, false, false, false, false, false, false, true,
110 false, false, false, false, false, true, false, false, false, false,
111 false, false, false, false, false, false, false, false, false, false,
112 false, false, false, false, false, false, false, false, false, false,
113 false, false, false, false, false, false, false, false, false, false,
114 false, false, false, false, false, false, false, false, false, false,
115 false, false, false, false, false, false, false, false, false, false,
116 false, false, false, false, false, false, false, false, false, false,
117 false, false, false, false, false, false, false, false, false, false,
118 false, false, false, false, false, false, false, true
119 };
120
122 {
123 m_name = culture._name;
125 }
126
128 {
129 if (assembly == null)
130 {
131 throw new ArgumentNullException("assembly");
132 }
133 if (assembly != typeof(object).Module.Assembly)
134 {
135 throw new ArgumentException(SR.Argument_OnlyMscorlib, "assembly");
136 }
137 return GetCompareInfo(culture);
138 }
139
140 public static CompareInfo GetCompareInfo(string name, Assembly assembly)
141 {
142 if (name == null)
143 {
144 throw new ArgumentNullException("name");
145 }
146 if (assembly == null)
147 {
148 throw new ArgumentNullException("assembly");
149 }
150 if (assembly != typeof(object).Module.Assembly)
151 {
152 throw new ArgumentException(SR.Argument_OnlyMscorlib, "assembly");
153 }
154 return GetCompareInfo(name);
155 }
156
158 {
160 {
162 }
163 return CultureInfo.GetCultureInfo(culture).CompareInfo;
164 }
165
166 public static CompareInfo GetCompareInfo(string name)
167 {
168 if (name == null)
169 {
170 throw new ArgumentNullException("name");
171 }
172 return CultureInfo.GetCultureInfo(name).CompareInfo;
173 }
174
175 public static bool IsSortable(char ch)
176 {
177 return IsSortable(MemoryMarshal.CreateReadOnlySpan(ref ch, 1));
178 }
179
180 public static bool IsSortable(string text)
181 {
182 if (text == null)
183 {
184 throw new ArgumentNullException("text");
185 }
186 return IsSortable(text.AsSpan());
187 }
188
190 {
191 if (text.Length == 0)
192 {
193 return false;
194 }
196 {
197 return true;
198 }
200 {
201 return IcuIsSortable(text);
202 }
203 return NlsIsSortable(text);
204 }
205
206 public static bool IsSortable(Rune value)
207 {
209 return IsSortable(destination[..value.EncodeToUtf16(destination)]);
210 }
211
212 [MemberNotNull("_sortName")]
214 {
215 _sortName = culture.SortName;
217 {
219 }
220 else
221 {
223 }
224 }
225
228 {
229 m_name = null;
230 }
231
233 {
235 }
236
239 {
241 }
242
243 private void OnDeserialized()
244 {
245 if (m_name == null)
246 {
248 }
249 else
250 {
252 }
253 }
254
260
261 public int Compare(string? string1, string? string2)
262 {
263 return Compare(string1, string2, CompareOptions.None);
264 }
265
266 public int Compare(string? string1, string? string2, CompareOptions options)
267 {
268 int result;
269 if (string1 == null)
270 {
271 result = ((string2 != null) ? (-1) : 0);
272 }
273 else
274 {
275 if (string2 != null)
276 {
277 return Compare(string1.AsSpan(), string2.AsSpan(), options);
278 }
279 result = 1;
280 }
282 return result;
283 }
284
293
294 public int Compare(string? string1, int offset1, int length1, string? string2, int offset2, int length2)
295 {
297 }
298
299 public int Compare(string? string1, int offset1, string? string2, int offset2, CompareOptions options)
300 {
301 return Compare(string1, offset1, (string1 != null) ? (string1.Length - offset1) : 0, string2, offset2, (string2 != null) ? (string2.Length - offset2) : 0, options);
302 }
303
304 public int Compare(string? string1, int offset1, string? string2, int offset2)
305 {
307 }
308
309 public int Compare(string? string1, int offset1, int length1, string? string2, int offset2, int length2, CompareOptions options)
310 {
313 if (string1 == null)
314 {
315 if (offset1 == 0 && length1 == 0)
316 {
317 goto IL_0027;
318 }
319 }
320 else if (string1.TryGetSpan(offset1, length1, out slice))
321 {
322 goto IL_0027;
323 }
324 goto IL_006e;
325 IL_0044:
326 int result;
327 if (string1 == null)
328 {
329 result = ((string2 != null) ? (-1) : 0);
330 }
331 else
332 {
333 if (string2 != null)
334 {
335 return Compare(slice, slice2, options);
336 }
337 result = 1;
338 }
340 return result;
341 IL_0027:
342 if (string2 == null)
343 {
344 if (offset2 == 0 && length2 == 0)
345 {
346 goto IL_0044;
347 }
348 }
349 else if (string2.TryGetSpan(offset2, length2, out slice2))
350 {
351 goto IL_0044;
352 }
353 goto IL_006e;
354 IL_006e:
355 if (length1 < 0 || length2 < 0)
356 {
357 throw new ArgumentOutOfRangeException((length1 < 0) ? "length1" : "length2", SR.ArgumentOutOfRange_NeedPosNum);
358 }
359 if (offset1 < 0 || offset2 < 0)
360 {
361 throw new ArgumentOutOfRangeException((offset1 < 0) ? "offset1" : "offset2", SR.ArgumentOutOfRange_NeedPosNum);
362 }
363 if (offset1 > (string1?.Length ?? 0) - length1)
364 {
366 }
368 }
369
371 {
372 if (string1 == string2)
373 {
375 return 0;
376 }
377 if ((options & ~(CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreSymbols | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.StringSort)) == 0)
378 {
380 {
382 }
383 if ((options & CompareOptions.IgnoreCase) == 0)
384 {
385 return string1.SequenceCompareTo(string2);
386 }
387 return Ordinal.CompareStringIgnoreCase(ref MemoryMarshal.GetReference(string1), string1.Length, ref MemoryMarshal.GetReference(string2), string2.Length);
388 }
389 switch (options)
390 {
391 case CompareOptions.Ordinal:
392 return string1.SequenceCompareTo(string2);
393 case CompareOptions.OrdinalIgnoreCase:
394 return Ordinal.CompareStringIgnoreCase(ref MemoryMarshal.GetReference(string1), string1.Length, ref MemoryMarshal.GetReference(string2), string2.Length);
395 default:
397 return -1;
398 }
399 }
400
401 [MethodImpl(MethodImplOptions.AggressiveInlining)]
404 {
405 if (((uint)options & 0xDFFFFFE0u) != 0 && options != CompareOptions.Ordinal && options != CompareOptions.OrdinalIgnoreCase)
406 {
408 }
409 }
410
417
426
427 public bool IsPrefix(string source, string prefix, CompareOptions options)
428 {
429 if (source == null)
430 {
432 }
433 if (prefix == null)
434 {
436 }
437 return IsPrefix(source.AsSpan(), prefix.AsSpan(), options);
438 }
439
441 {
442 if (prefix.IsEmpty)
443 {
444 return true;
445 }
446 if ((options & ~(CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreSymbols | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth)) == 0)
447 {
449 {
450 return StartsWithCore(source, prefix, options, null);
451 }
452 if ((options & CompareOptions.IgnoreCase) == 0)
453 {
454 return source.StartsWith(prefix);
455 }
456 return source.StartsWithOrdinalIgnoreCase(prefix);
457 }
458 switch (options)
459 {
460 case CompareOptions.Ordinal:
461 return source.StartsWith(prefix);
462 case CompareOptions.OrdinalIgnoreCase:
463 return source.StartsWithOrdinalIgnoreCase(prefix);
464 default:
466 return false;
467 }
468 }
469
471 {
472 bool flag;
473 if (GlobalizationMode.Invariant || prefix.IsEmpty || ((uint)options & 0xFFFFFFE0u) != 0)
474 {
475 flag = IsPrefix(source, prefix, options);
476 matchLength = (flag ? prefix.Length : 0);
477 }
478 else
479 {
480 int num = 0;
481 flag = StartsWithCore(source, prefix, options, &num);
482 matchLength = num;
483 }
484 return flag;
485 }
486
495
496 public bool IsPrefix(string source, string prefix)
497 {
498 return IsPrefix(source, prefix, CompareOptions.None);
499 }
500
501 public bool IsSuffix(string source, string suffix, CompareOptions options)
502 {
503 if (source == null)
504 {
506 }
507 if (suffix == null)
508 {
510 }
511 return IsSuffix(source.AsSpan(), suffix.AsSpan(), options);
512 }
513
515 {
516 if (suffix.IsEmpty)
517 {
518 return true;
519 }
520 if ((options & ~(CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreSymbols | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth)) == 0)
521 {
523 {
524 return EndsWithCore(source, suffix, options, null);
525 }
526 if ((options & CompareOptions.IgnoreCase) == 0)
527 {
528 return source.EndsWith(suffix);
529 }
530 return source.EndsWithOrdinalIgnoreCase(suffix);
531 }
532 switch (options)
533 {
534 case CompareOptions.Ordinal:
535 return source.EndsWith(suffix);
536 case CompareOptions.OrdinalIgnoreCase:
537 return source.EndsWithOrdinalIgnoreCase(suffix);
538 default:
540 return false;
541 }
542 }
543
545 {
546 bool flag;
547 if (GlobalizationMode.Invariant || suffix.IsEmpty || ((uint)options & 0xFFFFFFE0u) != 0)
548 {
549 flag = IsSuffix(source, suffix, options);
550 matchLength = (flag ? suffix.Length : 0);
551 }
552 else
553 {
554 int num = 0;
555 flag = EndsWithCore(source, suffix, options, &num);
556 matchLength = num;
557 }
558 return flag;
559 }
560
561 public bool IsSuffix(string source, string suffix)
562 {
563 return IsSuffix(source, suffix, CompareOptions.None);
564 }
565
574
575 public int IndexOf(string source, char value)
576 {
577 return IndexOf(source, value, CompareOptions.None);
578 }
579
580 public int IndexOf(string source, string value)
581 {
582 return IndexOf(source, value, CompareOptions.None);
583 }
584
585 public int IndexOf(string source, char value, CompareOptions options)
586 {
587 if (source == null)
588 {
590 }
591 return IndexOf(source, MemoryMarshal.CreateReadOnlySpan(ref value, 1), options);
592 }
593
594 public int IndexOf(string source, string value, CompareOptions options)
595 {
596 if (source == null)
597 {
599 }
600 if (value == null)
601 {
603 }
604 return IndexOf(source.AsSpan(), value.AsSpan(), options);
605 }
606
607 public int IndexOf(string source, char value, int startIndex)
608 {
610 }
611
612 public int IndexOf(string source, string value, int startIndex)
613 {
615 }
616
617 public int IndexOf(string source, char value, int startIndex, CompareOptions options)
618 {
619 if (source == null)
620 {
622 }
624 }
625
626 public int IndexOf(string source, string value, int startIndex, CompareOptions options)
627 {
628 if (source == null)
629 {
631 }
633 }
634
635 public int IndexOf(string source, char value, int startIndex, int count)
636 {
638 }
639
640 public int IndexOf(string source, string value, int startIndex, int count)
641 {
643 }
644
645 public int IndexOf(string source, char value, int startIndex, int count, CompareOptions options)
646 {
647 if (source == null)
648 {
650 }
651 if (!source.TryGetSpan(startIndex, count, out var slice))
652 {
653 if ((uint)startIndex > (uint)source.Length)
654 {
656 }
657 else
658 {
660 }
661 }
662 int num = IndexOf(slice, MemoryMarshal.CreateReadOnlySpan(ref value, 1), options);
663 if (num >= 0)
664 {
665 num += startIndex;
666 }
667 return num;
668 }
669
670 public int IndexOf(string source, string value, int startIndex, int count, CompareOptions options)
671 {
672 if (source == null)
673 {
675 }
676 if (value == null)
677 {
679 }
680 if (!source.TryGetSpan(startIndex, count, out var slice))
681 {
682 if ((uint)startIndex > (uint)source.Length)
683 {
685 }
686 else
687 {
689 }
690 }
691 int num = IndexOf(slice, value, options);
692 if (num >= 0)
693 {
694 num += startIndex;
695 }
696 return num;
697 }
698
700 {
701 if ((options & ~(CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreSymbols | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth)) == 0)
702 {
704 {
705 if (value.IsEmpty)
706 {
707 return 0;
708 }
709 return IndexOfCore(source, value, options, null, fromBeginning: true);
710 }
711 if ((options & CompareOptions.IgnoreCase) == 0)
712 {
713 return source.IndexOf(value);
714 }
716 }
717 switch (options)
718 {
719 case CompareOptions.Ordinal:
720 return source.IndexOf(value);
721 case CompareOptions.OrdinalIgnoreCase:
723 default:
725 return -1;
726 }
727 }
728
730 {
731 System.Runtime.CompilerServices.Unsafe.SkipInit(out int num);
732 int result = IndexOf(source, value, &num, options, fromBeginning: true);
733 matchLength = num;
734 return result;
735 }
736
742
744 {
745 *matchLengthPtr = 0;
746 int num = 0;
747 if ((options & ~(CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreSymbols | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth)) == 0)
748 {
750 {
751 if (value.IsEmpty)
752 {
753 if (!fromBeginning)
754 {
755 return source.Length;
756 }
757 return 0;
758 }
760 }
762 }
763 else
764 {
765 switch (options)
766 {
767 case CompareOptions.Ordinal:
768 num = (fromBeginning ? source.IndexOf(value) : source.LastIndexOf(value));
769 break;
770 case CompareOptions.OrdinalIgnoreCase:
772 break;
773 default:
775 break;
776 }
777 }
778 if (num >= 0)
779 {
780 *matchLengthPtr = value.Length;
781 }
782 return num;
783 }
784
793
794 public int LastIndexOf(string source, char value)
795 {
796 return LastIndexOf(source, value, CompareOptions.None);
797 }
798
799 public int LastIndexOf(string source, string value)
800 {
801 return LastIndexOf(source, value, CompareOptions.None);
802 }
803
805 {
806 if (source == null)
807 {
809 }
810 return LastIndexOf(source, MemoryMarshal.CreateReadOnlySpan(ref value, 1), options);
811 }
812
813 public int LastIndexOf(string source, string value, CompareOptions options)
814 {
815 if (source == null)
816 {
818 }
819 if (value == null)
820 {
822 }
823 return LastIndexOf(source.AsSpan(), value.AsSpan(), options);
824 }
825
826 public int LastIndexOf(string source, char value, int startIndex)
827 {
829 }
830
831 public int LastIndexOf(string source, string value, int startIndex)
832 {
834 }
835
837 {
839 }
840
841 public int LastIndexOf(string source, string value, int startIndex, CompareOptions options)
842 {
844 }
845
846 public int LastIndexOf(string source, char value, int startIndex, int count)
847 {
849 }
850
851 public int LastIndexOf(string source, string value, int startIndex, int count)
852 {
854 }
855
856 public int LastIndexOf(string source, char value, int startIndex, int count, CompareOptions options)
857 {
858 if (source == null)
859 {
861 }
862 while ((uint)startIndex >= (uint)source.Length)
863 {
864 if (startIndex == -1 && source.Length == 0)
865 {
866 count = 0;
867 break;
868 }
869 if (startIndex == source.Length)
870 {
871 startIndex--;
872 if (count > 0)
873 {
874 count--;
875 }
876 continue;
877 }
879 break;
880 }
882 if (!source.TryGetSpan(startIndex, count, out var slice))
883 {
885 }
886 int num = LastIndexOf(slice, MemoryMarshal.CreateReadOnlySpan(ref value, 1), options);
887 if (num >= 0)
888 {
889 num += startIndex;
890 }
891 return num;
892 }
893
894 public int LastIndexOf(string source, string value, int startIndex, int count, CompareOptions options)
895 {
896 if (source == null)
897 {
899 }
900 if (value == null)
901 {
903 }
904 while ((uint)startIndex >= (uint)source.Length)
905 {
906 if (startIndex == -1 && source.Length == 0)
907 {
908 count = 0;
909 break;
910 }
911 if (startIndex == source.Length)
912 {
913 startIndex--;
914 if (count > 0)
915 {
916 count--;
917 }
918 continue;
919 }
921 break;
922 }
924 if (!source.TryGetSpan(startIndex, count, out var slice))
925 {
927 }
928 int num = LastIndexOf(slice, value, options);
929 if (num >= 0)
930 {
931 num += startIndex;
932 }
933 return num;
934 }
935
937 {
938 if ((options & ~(CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreSymbols | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth)) == 0)
939 {
941 {
942 if (value.IsEmpty)
943 {
944 return source.Length;
945 }
946 return IndexOfCore(source, value, options, null, fromBeginning: false);
947 }
948 if ((options & CompareOptions.IgnoreCase) == 0)
949 {
950 return source.LastIndexOf(value);
951 }
953 }
954 return options switch
955 {
956 CompareOptions.Ordinal => source.LastIndexOf(value),
958 _ => throw new ArgumentException(SR.Argument_InvalidFlag, "options"),
959 };
960 }
961
963 {
964 System.Runtime.CompilerServices.Unsafe.SkipInit(out int num);
965 int result = IndexOf(source, value, &num, options, fromBeginning: false);
966 matchLength = num;
967 return result;
968 }
969
975
984
985 public SortKey GetSortKey(string source)
986 {
988 {
990 }
992 }
993
995 {
997 {
999 }
1001 }
1002
1004 {
1005 if (((uint)options & 0xDFFFFFE0u) != 0)
1006 {
1008 }
1010 {
1012 }
1014 }
1015
1024
1026 {
1027 if (((uint)options & 0xDFFFFFE0u) != 0)
1028 {
1030 }
1032 {
1034 }
1036 }
1037
1046
1047 public override bool Equals([NotNullWhen(true)] object? value)
1048 {
1050 {
1051 return Name == compareInfo.Name;
1052 }
1053 return false;
1054 }
1055
1056 public override int GetHashCode()
1057 {
1058 return Name.GetHashCode();
1059 }
1060
1062 {
1063 if (source == null)
1064 {
1066 }
1067 return GetHashCode(source.AsSpan(), options);
1068 }
1069
1071 {
1072 if ((options & ~(CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreSymbols | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.StringSort)) == 0)
1073 {
1075 {
1077 }
1078 if ((options & CompareOptions.IgnoreCase) == 0)
1079 {
1080 return string.GetHashCode(source);
1081 }
1082 return string.GetHashCodeOrdinalIgnoreCase(source);
1083 }
1084 switch (options)
1085 {
1086 case CompareOptions.Ordinal:
1087 return string.GetHashCode(source);
1088 case CompareOptions.OrdinalIgnoreCase:
1089 return string.GetHashCodeOrdinalIgnoreCase(source);
1090 default:
1092 return -1;
1093 }
1094 }
1095
1104
1105 public override string ToString()
1106 {
1107 return "CompareInfo - " + Name;
1108 }
1109
1110 private void IcuInitSortHandle()
1111 {
1113 {
1115 return;
1116 }
1117 _isAsciiEqualityOrdinal = _sortName.Length == 0 || (_sortName.Length >= 2 && _sortName[0] == 'e' && _sortName[1] == 'n' && (_sortName.Length == 2 || _sortName[2] == '-'));
1119 }
1120
1122 {
1123 fixed (char* lpStr = &MemoryMarshal.GetReference(string1))
1124 {
1125 fixed (char* lpStr2 = &MemoryMarshal.GetReference(string2))
1126 {
1128 }
1129 }
1130 }
1131
1133 {
1135 {
1136 if ((options & CompareOptions.IgnoreCase) != 0)
1137 {
1139 }
1141 }
1142 fixed (char* pSource = &MemoryMarshal.GetReference(source))
1143 {
1144 fixed (char* target2 = &MemoryMarshal.GetReference(target))
1145 {
1146 if (fromBeginning)
1147 {
1149 }
1151 }
1152 }
1153 }
1154
1156 {
1157 fixed (char* ptr = &MemoryMarshal.GetReference(source))
1158 {
1159 fixed (char* ptr3 = &MemoryMarshal.GetReference(target))
1160 {
1161 char* ptr2 = ptr;
1162 char* ptr4 = ptr3;
1163 int num = 0;
1164 while (true)
1165 {
1166 if (num < target.Length)
1167 {
1168 char c = ptr4[num];
1169 if (c >= '\u0080' || HighCharTable[c])
1170 {
1171 break;
1172 }
1173 num++;
1174 continue;
1175 }
1176 if (target.Length > source.Length)
1177 {
1178 int num2 = 0;
1179 while (true)
1180 {
1181 if (num2 < source.Length)
1182 {
1183 char c2 = ptr2[num2];
1184 if (c2 >= '\u0080' || HighCharTable[c2])
1185 {
1186 break;
1187 }
1188 num2++;
1189 continue;
1190 }
1191 return -1;
1192 }
1193 break;
1194 }
1195 int num3;
1196 int num4;
1197 int num5;
1198 if (fromBeginning)
1199 {
1200 num3 = 0;
1202 num5 = 1;
1203 }
1204 else
1205 {
1206 num3 = source.Length - target.Length;
1207 num4 = -1;
1208 num5 = -1;
1209 }
1210 int num6 = num3;
1211 while (true)
1212 {
1213 int num8;
1214 if (num6 != num4)
1215 {
1216 int num7 = 0;
1217 num8 = num6;
1218 while (true)
1219 {
1220 if (num7 < target.Length)
1221 {
1222 char c3 = ptr2[num8];
1223 char c4 = ptr4[num7];
1224 if (c3 >= '\u0080' || HighCharTable[c3])
1225 {
1226 break;
1227 }
1228 if (c3 == c4)
1229 {
1230 goto IL_0184;
1231 }
1232 if ((uint)(c3 - 97) <= 25u)
1233 {
1234 c3 = (char)(c3 - 32);
1235 }
1236 if ((uint)(c4 - 97) <= 25u)
1237 {
1238 c4 = (char)(c4 - 32);
1239 }
1240 if (c3 == c4)
1241 {
1242 goto IL_0184;
1243 }
1244 goto IL_0163;
1245 }
1246 if (num8 < source.Length && ptr2[num8] >= '\u0080')
1247 {
1248 break;
1249 }
1250 if (matchLengthPtr != null)
1251 {
1252 *matchLengthPtr = target.Length;
1253 }
1254 return num6;
1255 IL_0184:
1256 num7++;
1257 num8++;
1258 }
1259 break;
1260 }
1261 return -1;
1262 IL_0163:
1263 if (num8 < source.Length - 1 && (ptr2 + num8)[1] >= '\u0080')
1264 {
1265 break;
1266 }
1267 num6 += num5;
1268 }
1269 break;
1270 }
1271 if (fromBeginning)
1272 {
1273 return Interop.Globalization.IndexOf(_sortHandle, ptr4, target.Length, ptr2, source.Length, options, matchLengthPtr);
1274 }
1276 }
1277 }
1278 }
1279
1281 {
1282 fixed (char* ptr = &MemoryMarshal.GetReference(source))
1283 {
1284 fixed (char* ptr3 = &MemoryMarshal.GetReference(target))
1285 {
1286 char* ptr2 = ptr;
1287 char* ptr4 = ptr3;
1288 int num = 0;
1289 while (true)
1290 {
1291 if (num < target.Length)
1292 {
1293 char c = ptr4[num];
1294 if (c >= '\u0080' || HighCharTable[c])
1295 {
1296 break;
1297 }
1298 num++;
1299 continue;
1300 }
1301 if (target.Length > source.Length)
1302 {
1303 int num2 = 0;
1304 while (true)
1305 {
1306 if (num2 < source.Length)
1307 {
1308 char c2 = ptr2[num2];
1309 if (c2 >= '\u0080' || HighCharTable[c2])
1310 {
1311 break;
1312 }
1313 num2++;
1314 continue;
1315 }
1316 return -1;
1317 }
1318 break;
1319 }
1320 int num3;
1321 int num4;
1322 int num5;
1323 if (fromBeginning)
1324 {
1325 num3 = 0;
1327 num5 = 1;
1328 }
1329 else
1330 {
1331 num3 = source.Length - target.Length;
1332 num4 = -1;
1333 num5 = -1;
1334 }
1335 int num6 = num3;
1336 while (true)
1337 {
1338 int num8;
1339 if (num6 != num4)
1340 {
1341 int num7 = 0;
1342 num8 = num6;
1343 while (true)
1344 {
1345 if (num7 < target.Length)
1346 {
1347 char c3 = ptr2[num8];
1348 char c4 = ptr4[num7];
1349 if (c3 >= '\u0080' || HighCharTable[c3])
1350 {
1351 break;
1352 }
1353 if (c3 == c4)
1354 {
1355 num7++;
1356 num8++;
1357 continue;
1358 }
1359 goto IL_0135;
1360 }
1361 if (num8 < source.Length && ptr2[num8] >= '\u0080')
1362 {
1363 break;
1364 }
1365 if (matchLengthPtr != null)
1366 {
1367 *matchLengthPtr = target.Length;
1368 }
1369 return num6;
1370 }
1371 break;
1372 }
1373 return -1;
1374 IL_0135:
1375 if (num8 < source.Length - 1 && (ptr2 + num8)[1] >= '\u0080')
1376 {
1377 break;
1378 }
1379 num6 += num5;
1380 }
1381 break;
1382 }
1383 if (fromBeginning)
1384 {
1385 return Interop.Globalization.IndexOf(_sortHandle, ptr4, target.Length, ptr2, source.Length, options, matchLengthPtr);
1386 }
1388 }
1389 }
1390 }
1391
1393 {
1395 {
1396 if ((options & CompareOptions.IgnoreCase) != 0)
1397 {
1399 }
1401 }
1402 fixed (char* source2 = &MemoryMarshal.GetReference(source))
1403 {
1404 fixed (char* target = &MemoryMarshal.GetReference(prefix))
1405 {
1407 }
1408 }
1409 }
1410
1412 {
1413 int num = Math.Min(source.Length, prefix.Length);
1414 fixed (char* ptr = &MemoryMarshal.GetReference(source))
1415 {
1416 fixed (char* ptr3 = &MemoryMarshal.GetReference(prefix))
1417 {
1418 char* ptr2 = ptr;
1419 char* ptr4 = ptr3;
1420 while (true)
1421 {
1422 if (num != 0)
1423 {
1424 int num2 = *ptr2;
1425 int num3 = *ptr4;
1426 if (num2 >= 128 || num3 >= 128 || HighCharTable[num2] || HighCharTable[num3])
1427 {
1428 break;
1429 }
1430 if (num2 == num3)
1431 {
1432 ptr2++;
1433 ptr4++;
1434 num--;
1435 continue;
1436 }
1437 if ((uint)(num2 - 97) <= 25u)
1438 {
1439 num2 -= 32;
1440 }
1441 if ((uint)(num3 - 97) <= 25u)
1442 {
1443 num3 -= 32;
1444 }
1445 if (num2 == num3)
1446 {
1447 ptr2++;
1448 ptr4++;
1449 num--;
1450 continue;
1451 }
1452 if ((ptr2 < ptr + source.Length - 1 && ptr2[1] >= '\u0080') || (ptr4 < ptr3 + prefix.Length - 1 && ptr4[1] >= '\u0080'))
1453 {
1454 break;
1455 }
1456 return false;
1457 }
1458 if (source.Length < prefix.Length)
1459 {
1460 if (*ptr4 >= '\u0080')
1461 {
1462 break;
1463 }
1464 return false;
1465 }
1466 if (source.Length > prefix.Length && *ptr2 >= '\u0080')
1467 {
1468 break;
1469 }
1470 if (matchLengthPtr != null)
1471 {
1472 *matchLengthPtr = prefix.Length;
1473 }
1474 return true;
1475 }
1477 }
1478 }
1479 }
1480
1482 {
1483 int num = Math.Min(source.Length, prefix.Length);
1484 fixed (char* ptr = &MemoryMarshal.GetReference(source))
1485 {
1486 fixed (char* ptr3 = &MemoryMarshal.GetReference(prefix))
1487 {
1488 char* ptr2 = ptr;
1489 char* ptr4 = ptr3;
1490 while (true)
1491 {
1492 if (num != 0)
1493 {
1494 int num2 = *ptr2;
1495 int num3 = *ptr4;
1496 if (num2 >= 128 || num3 >= 128 || HighCharTable[num2] || HighCharTable[num3])
1497 {
1498 break;
1499 }
1500 if (num2 == num3)
1501 {
1502 ptr2++;
1503 ptr4++;
1504 num--;
1505 continue;
1506 }
1507 if ((ptr2 < ptr + source.Length - 1 && ptr2[1] >= '\u0080') || (ptr4 < ptr3 + prefix.Length - 1 && ptr4[1] >= '\u0080'))
1508 {
1509 break;
1510 }
1511 return false;
1512 }
1513 if (source.Length < prefix.Length)
1514 {
1515 if (*ptr4 >= '\u0080')
1516 {
1517 break;
1518 }
1519 return false;
1520 }
1521 if (source.Length > prefix.Length && *ptr2 >= '\u0080')
1522 {
1523 break;
1524 }
1525 if (matchLengthPtr != null)
1526 {
1527 *matchLengthPtr = prefix.Length;
1528 }
1529 return true;
1530 }
1532 }
1533 }
1534 }
1535
1537 {
1539 {
1540 if ((options & CompareOptions.IgnoreCase) != 0)
1541 {
1543 }
1545 }
1546 fixed (char* source2 = &MemoryMarshal.GetReference(source))
1547 {
1548 fixed (char* target = &MemoryMarshal.GetReference(suffix))
1549 {
1551 }
1552 }
1553 }
1554
1556 {
1557 int num = Math.Min(source.Length, suffix.Length);
1558 fixed (char* ptr = &MemoryMarshal.GetReference(source))
1559 {
1560 fixed (char* ptr3 = &MemoryMarshal.GetReference(suffix))
1561 {
1562 char* ptr2 = ptr + source.Length - 1;
1563 char* ptr4 = ptr3 + suffix.Length - 1;
1564 while (true)
1565 {
1566 if (num != 0)
1567 {
1568 int num2 = *ptr2;
1569 int num3 = *ptr4;
1570 if (num2 >= 128 || num3 >= 128 || HighCharTable[num2] || HighCharTable[num3])
1571 {
1572 break;
1573 }
1574 if (num2 == num3)
1575 {
1576 ptr2--;
1577 ptr4--;
1578 num--;
1579 continue;
1580 }
1581 if ((uint)(num2 - 97) <= 25u)
1582 {
1583 num2 -= 32;
1584 }
1585 if ((uint)(num3 - 97) <= 25u)
1586 {
1587 num3 -= 32;
1588 }
1589 if (num2 == num3)
1590 {
1591 ptr2--;
1592 ptr4--;
1593 num--;
1594 continue;
1595 }
1596 if ((ptr2 > ptr && *(ptr2 - 1) >= '\u0080') || (ptr4 > ptr3 && *(ptr4 - 1) >= '\u0080'))
1597 {
1598 break;
1599 }
1600 return false;
1601 }
1602 if (source.Length < suffix.Length)
1603 {
1604 if (*ptr4 >= '\u0080')
1605 {
1606 break;
1607 }
1608 return false;
1609 }
1610 if (source.Length > suffix.Length && *ptr2 >= '\u0080')
1611 {
1612 break;
1613 }
1614 if (matchLengthPtr != null)
1615 {
1616 *matchLengthPtr = suffix.Length;
1617 }
1618 return true;
1619 }
1621 }
1622 }
1623 }
1624
1626 {
1627 int num = Math.Min(source.Length, suffix.Length);
1628 fixed (char* ptr = &MemoryMarshal.GetReference(source))
1629 {
1630 fixed (char* ptr3 = &MemoryMarshal.GetReference(suffix))
1631 {
1632 char* ptr2 = ptr + source.Length - 1;
1633 char* ptr4 = ptr3 + suffix.Length - 1;
1634 while (true)
1635 {
1636 if (num != 0)
1637 {
1638 int num2 = *ptr2;
1639 int num3 = *ptr4;
1640 if (num2 >= 128 || num3 >= 128 || HighCharTable[num2] || HighCharTable[num3])
1641 {
1642 break;
1643 }
1644 if (num2 == num3)
1645 {
1646 ptr2--;
1647 ptr4--;
1648 num--;
1649 continue;
1650 }
1651 if ((ptr2 > ptr && *(ptr2 - 1) >= '\u0080') || (ptr4 > ptr3 && *(ptr4 - 1) >= '\u0080'))
1652 {
1653 break;
1654 }
1655 return false;
1656 }
1657 if (source.Length < suffix.Length)
1658 {
1659 if (*ptr4 >= '\u0080')
1660 {
1661 break;
1662 }
1663 return false;
1664 }
1665 if (source.Length > suffix.Length && *ptr2 >= '\u0080')
1666 {
1667 break;
1668 }
1669 if (matchLengthPtr != null)
1670 {
1671 *matchLengthPtr = suffix.Length;
1672 }
1673 return true;
1674 }
1676 }
1677 }
1678 }
1679
1681 {
1682 if (source == null)
1683 {
1684 throw new ArgumentNullException("source");
1685 }
1686 if (((uint)options & 0xDFFFFFE0u) != 0)
1687 {
1688 throw new ArgumentException(SR.Argument_InvalidFlag, "options");
1689 }
1690 byte[] array;
1691 fixed (char* str = source)
1692 {
1694 array = new byte[sortKey];
1695 fixed (byte[] array2 = array)
1696 {
1698 {
1700 }
1701 }
1702 array2 = null;
1703 }
1704 return new SortKey(this, source, options, array);
1705 }
1706
1708 {
1709 int sortKey2;
1710 fixed (char* str = &MemoryMarshal.GetReference(source))
1711 {
1712 fixed (byte* sortKey = &MemoryMarshal.GetReference(destination))
1713 {
1715 }
1716 }
1717 if ((uint)sortKey2 > (uint)destination.Length)
1718 {
1719 if (sortKey2 <= destination.Length)
1720 {
1722 }
1724 }
1725 return sortKey2;
1726 }
1727
1729 {
1730 fixed (char* str = &MemoryMarshal.GetReference(source))
1731 {
1732 return Interop.Globalization.GetSortKey(_sortHandle, str, source.Length, null, 0, options);
1733 }
1734 }
1735
1737 {
1738 do
1739 {
1740 if (Rune.DecodeFromUtf16(text, out var result, out var charsConsumed) != 0)
1741 {
1742 return false;
1743 }
1745 if (unicodeCategory == UnicodeCategory.PrivateUse || unicodeCategory == UnicodeCategory.OtherNotAssigned)
1746 {
1747 return false;
1748 }
1749 text = text.Slice(charsConsumed);
1750 }
1751 while (!text.IsEmpty);
1752 return true;
1753 }
1754
1756 {
1757 int num = ((source.Length <= 262144) ? (4 * source.Length) : 0);
1758 byte[] array = null;
1759 Span<byte> span = ((num > 1024) ? ((Span<byte>)(array = ArrayPool<byte>.Shared.Rent(num))) : stackalloc byte[1024]);
1761 fixed (char* str = &MemoryMarshal.GetNonNullPinnableReference(source))
1762 {
1763 fixed (byte* sortKey = &MemoryMarshal.GetReference(span2))
1764 {
1766 }
1767 if (num > span2.Length)
1768 {
1769 if (array != null)
1770 {
1771 ArrayPool<byte>.Shared.Return(array);
1772 }
1773 span2 = (array = ArrayPool<byte>.Shared.Rent(num));
1774 fixed (byte* sortKey2 = &MemoryMarshal.GetReference(span2))
1775 {
1777 }
1778 }
1779 }
1780 if (num == 0 || num > span2.Length)
1781 {
1783 }
1784 int result = Marvin.ComputeHash32(span2.Slice(0, num), Marvin.DefaultSeed);
1785 if (array != null)
1786 {
1787 ArrayPool<byte>.Shared.Return(array);
1788 }
1789 return result;
1790 }
1791
1793 {
1794 return (options & CompareOptions.IgnoreSymbols) == 0;
1795 }
1796
1798 {
1800 return new SortVersion(sortVersion, LCID, new Guid(sortVersion, 0, 0, 0, 0, 0, 0, (byte)(LCID >> 24), (byte)((LCID & 0xFF0000) >> 16), (byte)((LCID & 0xFF00) >> 8), (byte)((uint)LCID & 0xFFu)));
1801 }
1802
1804 {
1805 if (source == null)
1806 {
1807 throw new ArgumentNullException("source");
1808 }
1809 if (((uint)options & 0xDFFFFFE0u) != 0)
1810 {
1811 throw new ArgumentException(SR.Argument_InvalidFlag, "options");
1812 }
1813 byte[] array;
1814 if (source.Length == 0)
1815 {
1816 array = Array.Empty<byte>();
1817 }
1818 else
1819 {
1820 array = new byte[source.Length * 2];
1821 if ((options & (CompareOptions.IgnoreCase | CompareOptions.OrdinalIgnoreCase)) != 0)
1822 {
1824 }
1825 else
1826 {
1828 }
1829 }
1830 return new SortKey(this, source, options, array);
1831 }
1832
1834 {
1835 for (int i = 0; i < source.Length; i++)
1836 {
1838 sortKey = sortKey.Slice(2);
1839 }
1840 }
1841
1843 {
1844 for (int i = 0; i < source.Length; i++)
1845 {
1846 char c = source[i];
1847 if (char.IsHighSurrogate(c) && i < source.Length - 1)
1848 {
1849 char c2 = source[i + 1];
1850 if (char.IsLowSurrogate(c2))
1851 {
1855 i++;
1856 sortKey = sortKey.Slice(4);
1857 continue;
1858 }
1859 }
1861 sortKey = sortKey.Slice(2);
1862 }
1863 }
1864
1866 {
1867 if ((uint)destination.Length < (uint)(source.Length * 2))
1868 {
1870 }
1871 if ((options & CompareOptions.IgnoreCase) == 0)
1872 {
1874 }
1875 else
1876 {
1878 }
1879 return source.Length * 2;
1880 }
1881
1883 {
1884 int num = source.Length * 2;
1885 if (num < 0)
1886 {
1888 }
1889 return num;
1890 }
1891
1892 private void NlsInitSortHandle()
1893 {
1895 }
1896
1897 internal unsafe static IntPtr NlsGetSortHandle(string cultureName)
1898 {
1900 {
1901 return IntPtr.Zero;
1902 }
1904 int num = Interop.Kernel32.LCMapStringEx(cultureName, 536870912u, null, 0, &intPtr, IntPtr.Size, null, null, IntPtr.Zero);
1905 if (num > 0)
1906 {
1907 int num2 = 0;
1908 char c = 'a';
1909 num = Interop.Kernel32.LCMapStringEx(null, 262144u, &c, 1, &num2, 4, null, null, intPtr);
1910 if (num > 1)
1911 {
1912 return intPtr;
1913 }
1914 }
1915 return IntPtr.Zero;
1916 }
1917
1919 {
1920 fixed (char* lpStringSource = &MemoryMarshal.GetReference(source))
1921 {
1922 fixed (char* lpStringValue = &MemoryMarshal.GetReference(value))
1923 {
1925 }
1926 }
1927 }
1928
1934
1936 {
1938 {
1939 source = source.ToString();
1940 }
1941 int num = source.Length;
1942 if (num == 0)
1943 {
1944 source = string.Empty;
1945 num = -1;
1946 }
1947 uint dwMapFlags = 0x400u | (uint)GetNativeCompareFlags(options);
1948 fixed (char* lpSrcStr = &MemoryMarshal.GetReference(source))
1949 {
1950 int num2 = Interop.Kernel32.LCMapStringEx((_sortHandle != IntPtr.Zero) ? null : _sortName, dwMapFlags, lpSrcStr, num, null, 0, null, null, _sortHandle);
1951 if (num2 == 0)
1952 {
1954 }
1955 byte[] array = null;
1956 Span<byte> span = ((num2 > 512) ? ((Span<byte>)(array = ArrayPool<byte>.Shared.Rent(num2))) : stackalloc byte[512]);
1958 fixed (byte* lpDestStr = &MemoryMarshal.GetReference(span2))
1959 {
1961 {
1963 }
1964 }
1965 int result = Marvin.ComputeHash32(span2.Slice(0, num2), Marvin.DefaultSeed);
1966 if (array != null)
1967 {
1968 ArrayPool<byte>.Shared.Return(array);
1969 }
1970 return result;
1971 }
1972 }
1973
1974 internal unsafe static int NlsCompareStringOrdinalIgnoreCase(ref char string1, int count1, ref char string2, int count2)
1975 {
1976 fixed (char* lpString = &string1)
1977 {
1978 fixed (char* lpString2 = &string2)
1979 {
1981 if (num == 0)
1982 {
1984 }
1985 return num - 2;
1986 }
1987 }
1988 }
1989
1991 {
1992 string text = ((_sortHandle != IntPtr.Zero) ? null : _sortName);
1993 if (string1.IsEmpty)
1994 {
1995 string1 = string.Empty;
1996 }
1997 if (string2.IsEmpty)
1998 {
1999 string2 = string.Empty;
2000 }
2001 fixed (char* lpLocaleName = text)
2002 {
2003 fixed (char* lpString = &MemoryMarshal.GetReference(string1))
2004 {
2005 fixed (char* lpString2 = &MemoryMarshal.GetReference(string2))
2006 {
2008 if (num == 0)
2009 {
2011 }
2012 return num - 2;
2013 }
2014 }
2015 }
2016 }
2017
2019 {
2020 string text = ((_sortHandle != IntPtr.Zero) ? null : _sortName);
2021 int num = lpStringSource.Length;
2022 if (num == 0)
2023 {
2024 lpStringSource = string.Empty;
2025 num = -1;
2026 }
2027 fixed (char* lpLocaleName = text)
2028 {
2029 fixed (char* lpStringSource2 = &MemoryMarshal.GetReference(lpStringSource))
2030 {
2031 fixed (char* lpStringValue2 = &MemoryMarshal.GetReference(lpStringValue))
2032 {
2034 }
2035 }
2036 }
2037 }
2038
2040 {
2041 uint num = (fromBeginning ? 4194304u : 8388608u);
2042 return FindString(num | (uint)GetNativeCompareFlags(options), source, target, matchLengthPtr);
2043 }
2044
2046 {
2048 if (num >= 0)
2049 {
2050 if (matchLengthPtr != null)
2051 {
2052 *matchLengthPtr += num;
2053 }
2054 return true;
2055 }
2056 return false;
2057 }
2058
2060 {
2061 int num = FindString(0x200000u | (uint)GetNativeCompareFlags(options), source, suffix, null);
2062 if (num >= 0)
2063 {
2064 if (matchLengthPtr != null)
2065 {
2067 }
2068 return true;
2069 }
2070 return false;
2071 }
2072
2074 {
2075 if (source == null)
2076 {
2077 throw new ArgumentNullException("source");
2078 }
2079 if (((uint)options & 0xDFFFFFE0u) != 0)
2080 {
2081 throw new ArgumentException(SR.Argument_InvalidFlag, "options");
2082 }
2083 uint dwMapFlags = 0x400u | (uint)GetNativeCompareFlags(options);
2084 int num = source.Length;
2085 if (num == 0)
2086 {
2087 num = -1;
2088 }
2089 byte[] array;
2090 fixed (char* lpSrcStr = source)
2091 {
2092 int num2 = Interop.Kernel32.LCMapStringEx((_sortHandle != IntPtr.Zero) ? null : _sortName, dwMapFlags, lpSrcStr, num, null, 0, null, null, _sortHandle);
2093 if (num2 == 0)
2094 {
2096 }
2097 array = new byte[num2];
2098 fixed (byte* lpDestStr = array)
2099 {
2100 if (Interop.Kernel32.LCMapStringEx((_sortHandle != IntPtr.Zero) ? null : _sortName, dwMapFlags, lpSrcStr, num, lpDestStr, array.Length, null, null, _sortHandle) != num2)
2101 {
2103 }
2104 }
2105 }
2106 return new SortKey(this, source, options, array);
2107 }
2108
2110 {
2111 if (destination.IsEmpty)
2112 {
2114 }
2116 {
2117 source = source.ToString();
2118 }
2119 uint dwMapFlags = 0x400u | (uint)GetNativeCompareFlags(options);
2120 int num = source.Length;
2121 if (num == 0)
2122 {
2123 source = string.Empty;
2124 num = -1;
2125 }
2126 int num3;
2127 fixed (char* lpSrcStr = &MemoryMarshal.GetReference(source))
2128 {
2129 fixed (byte* lpDestStr = &MemoryMarshal.GetReference(destination))
2130 {
2132 {
2133 int num2 = Interop.Kernel32.LCMapStringEx((_sortHandle != IntPtr.Zero) ? null : _sortName, dwMapFlags, lpSrcStr, num, null, 0, null, null, _sortHandle);
2134 if (num2 > destination.Length)
2135 {
2137 }
2138 if (num2 <= 0)
2139 {
2141 }
2142 }
2144 }
2145 }
2146 if (num3 <= 0)
2147 {
2148 if (Marshal.GetLastPInvokeError() != 122)
2149 {
2151 }
2153 }
2154 return num3;
2155 }
2156
2158 {
2159 uint dwMapFlags = 0x400u | (uint)GetNativeCompareFlags(options);
2160 int num = source.Length;
2161 if (num == 0)
2162 {
2163 source = string.Empty;
2164 num = -1;
2165 }
2166 int num2;
2167 fixed (char* lpSrcStr = &MemoryMarshal.GetReference(source))
2168 {
2169 num2 = Interop.Kernel32.LCMapStringEx((_sortHandle != IntPtr.Zero) ? null : _sortName, dwMapFlags, lpSrcStr, num, null, 0, null, null, _sortHandle);
2170 }
2171 if (num2 <= 0)
2172 {
2174 }
2175 return num2;
2176 }
2177
2178 private unsafe static bool NlsIsSortable(ReadOnlySpan<char> text)
2179 {
2180 fixed (char* lpString = &MemoryMarshal.GetReference(text))
2181 {
2183 }
2184 }
2185
2187 {
2188 int num = 134217728;
2189 if ((options & CompareOptions.IgnoreCase) != 0)
2190 {
2191 num |= 1;
2192 }
2193 if ((options & CompareOptions.IgnoreKanaType) != 0)
2194 {
2195 num |= 0x10000;
2196 }
2197 if ((options & CompareOptions.IgnoreNonSpace) != 0)
2198 {
2199 num |= 2;
2200 }
2201 if ((options & CompareOptions.IgnoreSymbols) != 0)
2202 {
2203 num |= 4;
2204 }
2205 if ((options & CompareOptions.IgnoreWidth) != 0)
2206 {
2207 num |= 0x20000;
2208 }
2209 if ((options & CompareOptions.StringSort) != 0)
2210 {
2211 num |= 0x1000;
2212 }
2213 if (options == CompareOptions.Ordinal)
2214 {
2215 num = 1073741824;
2216 }
2217 return num;
2218 }
2219
2227}
static unsafe int GetSortKey(IntPtr sortHandle, char *str, int strLength, byte *sortKey, int sortKeyLength, CompareOptions options)
static unsafe int IndexOf(IntPtr sortHandle, char *target, int cwTargetLength, char *pSource, int cwSourceLength, CompareOptions options, int *matchLengthPtr)
static void CloseSortHandle(IntPtr handle)
static ResultCode GetSortHandle(string localeName, out IntPtr sortHandle)
static int GetSortVersion(IntPtr sortHandle)
static unsafe bool StartsWith(IntPtr sortHandle, char *target, int cwTargetLength, char *source, int cwSourceLength, CompareOptions options, int *matchedLength)
static unsafe int CompareString(IntPtr sortHandle, char *lpStr1, int cwStr1Len, char *lpStr2, int cwStr2Len, CompareOptions options)
static unsafe int LastIndexOf(IntPtr sortHandle, char *target, int cwTargetLength, char *pSource, int cwSourceLength, CompareOptions options, int *matchLengthPtr)
static unsafe bool EndsWith(IntPtr sortHandle, char *target, int cwTargetLength, char *source, int cwSourceLength, CompareOptions options, int *matchedLength)
static unsafe int LCMapStringEx(string lpLocaleName, uint dwMapFlags, char *lpSrcStr, int cchSrc, void *lpDestStr, int cchDest, void *lpVersionInformation, void *lpReserved, IntPtr sortHandle)
static unsafe bool GetNLSVersionEx(int function, string localeName, NlsVersionInfoEx *lpVersionInformation)
static unsafe int CompareStringOrdinal(char *lpString1, int cchCount1, char *lpString2, int cchCount2, bool bIgnoreCase)
static unsafe int FindNLSStringEx(char *lpLocaleName, uint dwFindNLSStringFlags, char *lpStringSource, int cchSource, char *lpStringValue, int cchValue, int *pcchFound, void *lpVersionInformation, void *lpReserved, IntPtr sortHandle)
static unsafe int FindStringOrdinal(uint dwFindStringOrdinalFlags, char *lpStringSource, int cchSource, char *lpStringValue, int cchValue, BOOL bIgnoreCase)
static unsafe int CompareStringEx(char *lpLocaleName, uint dwCmpFlags, char *lpString1, int cchCount1, char *lpString2, int cchCount2, void *lpVersionInformation, void *lpReserved, IntPtr lParam)
static unsafe bool IsNLSDefinedString(int Function, uint dwFlags, IntPtr lpVersionInformation, char *lpString, int cchStr)
static void WriteUInt16BigEndian(Span< byte > destination, ushort value)
static bool IsWindows8OrAbove
static IntPtr GetCachedSortHandle(string sortName)
static readonly Dictionary< string, IntPtr > s_sortNameToSortHandleCache
unsafe int IndexOf(ReadOnlySpan< char > source, ReadOnlySpan< char > value, CompareOptions options, out int matchLength)
int IndexOf(string source, char value, int startIndex, int count, CompareOptions options)
int IndexOf(string source, char value, int startIndex)
unsafe SortVersion NlsGetSortVersion()
static int GetNativeCompareFlags(CompareOptions options)
int GetHashCode(ReadOnlySpan< char > source, CompareOptions options)
int LastIndexOf(string source, char value)
static readonly CompareInfo Invariant
void OnSerializing(StreamingContext ctx)
unsafe bool StartsWithOrdinalIgnoreCaseHelper(ReadOnlySpan< char > source, ReadOnlySpan< char > prefix, CompareOptions options, int *matchLengthPtr)
int LastIndexOf(ReadOnlySpan< char > source, Rune value, CompareOptions options=CompareOptions.None)
unsafe int IcuIndexOfCore(ReadOnlySpan< char > source, ReadOnlySpan< char > target, CompareOptions options, int *matchLengthPtr, bool fromBeginning)
unsafe int IcuCompareString(ReadOnlySpan< char > string1, ReadOnlySpan< char > string2, CompareOptions options)
unsafe bool NlsStartsWith(ReadOnlySpan< char > source, ReadOnlySpan< char > prefix, CompareOptions options, int *matchLengthPtr)
int Compare(ReadOnlySpan< char > string1, ReadOnlySpan< char > string2, CompareOptions options=CompareOptions.None)
int Compare(string? string1, string? string2, CompareOptions options)
int GetSortKey(ReadOnlySpan< char > source, Span< byte > destination, CompareOptions options=CompareOptions.None)
bool IsPrefix(string source, string prefix, CompareOptions options)
unsafe int IcuGetHashCodeOfString(ReadOnlySpan< char > source, CompareOptions options)
int GetHashCodeOfStringCore(ReadOnlySpan< char > source, CompareOptions options)
unsafe int IndexOfCore(ReadOnlySpan< char > source, ReadOnlySpan< char > target, CompareOptions options, int *matchLengthPtr, bool fromBeginning)
int IndexOf(string source, string value, int startIndex, CompareOptions options)
unsafe bool StartsWithCore(ReadOnlySpan< char > source, ReadOnlySpan< char > prefix, CompareOptions options, int *matchLengthPtr)
int Compare(string? string1, int offset1, string? string2, int offset2, CompareOptions options)
SortKey GetSortKey(string source, CompareOptions options)
int LastIndexOf(string source, string value, int startIndex)
void OnDeserialized(StreamingContext ctx)
static unsafe bool NlsIsSortable(ReadOnlySpan< char > text)
static CompareInfo GetCompareInfo(string name, Assembly assembly)
unsafe bool StartsWithOrdinalHelper(ReadOnlySpan< char > source, ReadOnlySpan< char > prefix, CompareOptions options, int *matchLengthPtr)
int Compare(string? string1, int offset1, int length1, string? string2, int offset2, int length2, CompareOptions options)
bool IsSuffix(string source, string suffix)
static int InvariantGetSortKeyLength(ReadOnlySpan< char > source, CompareOptions options)
static int NlsIndexOfOrdinalCore(ReadOnlySpan< char > source, ReadOnlySpan< char > value, bool ignoreCase, bool fromBeginning)
static CompareInfo GetCompareInfo(string name)
unsafe bool EndsWithOrdinalHelper(ReadOnlySpan< char > source, ReadOnlySpan< char > suffix, CompareOptions options, int *matchLengthPtr)
static void CheckCompareOptionsForCompare(CompareOptions options)
int IndexOf(string source, string value, int startIndex, int count)
static void InvariantCreateSortKeyOrdinal(ReadOnlySpan< char > source, Span< byte > sortKey)
unsafe bool IcuStartsWith(ReadOnlySpan< char > source, ReadOnlySpan< char > prefix, CompareOptions options, int *matchLengthPtr)
int IndexOf(string source, string value, int startIndex, int count, CompareOptions options)
SortKey InvariantCreateSortKey(string source, CompareOptions options)
static bool IsSortable(Rune value)
int IndexOf(string source, char value, int startIndex, CompareOptions options)
unsafe int FindString(uint dwFindNLSStringFlags, ReadOnlySpan< char > lpStringSource, ReadOnlySpan< char > lpStringValue, int *pcchFound)
int LastIndexOf(string source, char value, int startIndex, int count)
int LastIndexOf(string source, string value)
void OnDeserializing(StreamingContext ctx)
int IndexOf(string source, char value)
int Compare(string? string1, string? string2)
override bool Equals([NotNullWhen(true)] object? value)
static bool IsSortable(char ch)
unsafe bool IsPrefix(ReadOnlySpan< char > source, ReadOnlySpan< char > prefix, CompareOptions options=CompareOptions.None)
int GetHashCode(string source, CompareOptions options)
SortKey CreateSortKeyCore(string source, CompareOptions options)
unsafe bool EndsWithCore(ReadOnlySpan< char > source, ReadOnlySpan< char > suffix, CompareOptions options, int *matchLengthPtr)
unsafe int IndexOfOrdinalIgnoreCaseHelper(ReadOnlySpan< char > source, ReadOnlySpan< char > target, CompareOptions options, int *matchLengthPtr, bool fromBeginning)
static bool IsSortable(ReadOnlySpan< char > text)
int CompareStringCore(ReadOnlySpan< char > string1, ReadOnlySpan< char > string2, CompareOptions options)
unsafe bool IsSuffix(ReadOnlySpan< char > source, ReadOnlySpan< char > suffix, CompareOptions options, out int matchLength)
int LastIndexOf(string source, char value, int startIndex)
unsafe bool NlsEndsWith(ReadOnlySpan< char > source, ReadOnlySpan< char > suffix, CompareOptions options, int *matchLengthPtr)
unsafe bool EndsWithOrdinalIgnoreCaseHelper(ReadOnlySpan< char > source, ReadOnlySpan< char > suffix, CompareOptions options, int *matchLengthPtr)
static ReadOnlySpan< bool > HighCharTable
static CompareInfo GetCompareInfo(int culture)
static void InvariantCreateSortKeyOrdinalIgnoreCase(ReadOnlySpan< char > source, Span< byte > sortKey)
int Compare(string? string1, int offset1, string? string2, int offset2)
unsafe SortKey NlsCreateSortKey(string source, CompareOptions options)
unsafe int NlsCompareString(ReadOnlySpan< char > string1, ReadOnlySpan< char > string2, CompareOptions options)
int CompareOptionIgnoreCase(ReadOnlySpan< char > string1, ReadOnlySpan< char > string2)
int IndexOf(string source, string value, CompareOptions options)
static unsafe IntPtr NlsGetSortHandle(string cultureName)
static unsafe int NlsCompareStringOrdinalIgnoreCase(ref char string1, int count1, ref char string2, int count2)
static bool IcuIsSortable(ReadOnlySpan< char > text)
static unsafe int FindStringOrdinal(uint dwFindStringOrdinalFlags, ReadOnlySpan< char > source, ReadOnlySpan< char > value, bool bIgnoreCase)
unsafe int IndexOf(ReadOnlySpan< char > source, ReadOnlySpan< char > value, CompareOptions options=CompareOptions.None)
int LastIndexOf(string source, char value, int startIndex, CompareOptions options)
int GetSortKeyCore(ReadOnlySpan< char > source, Span< byte > destination, CompareOptions options)
unsafe int IcuGetSortKeyLength(ReadOnlySpan< char > source, CompareOptions options)
static CompareInfo GetCompareInfo(int culture, Assembly assembly)
int GetSortKeyLengthCore(ReadOnlySpan< char > source, CompareOptions options)
int IndexOf(string source, string value)
int LastIndexOf(string source, char value, CompareOptions options)
static void ThrowCompareOptionsCheckFailed(CompareOptions options)
SortKey GetSortKey(string source)
static bool CanUseAsciiOrdinalForOptions(CompareOptions options)
int IndexOf(string source, char value, CompareOptions options)
bool IsPrefix(string source, string prefix)
unsafe SortKey IcuCreateSortKey(string source, CompareOptions options)
unsafe int NlsGetSortKeyLength(ReadOnlySpan< char > source, CompareOptions options)
unsafe int LastIndexOf(ReadOnlySpan< char > source, ReadOnlySpan< char > value, CompareOptions options, out int matchLength)
unsafe int IndexOfOrdinalHelper(ReadOnlySpan< char > source, ReadOnlySpan< char > target, CompareOptions options, int *matchLengthPtr, bool fromBeginning)
int LastIndexOf(string source, string value, int startIndex, CompareOptions options)
int IndexOf(ReadOnlySpan< char > source, Rune value, CompareOptions options=CompareOptions.None)
unsafe int NlsGetSortKey(ReadOnlySpan< char > source, Span< byte > destination, CompareOptions options)
unsafe bool IsSuffix(ReadOnlySpan< char > source, ReadOnlySpan< char > suffix, CompareOptions options=CompareOptions.None)
unsafe int NlsGetHashCodeOfString(ReadOnlySpan< char > source, CompareOptions options)
int LastIndexOf(string source, string value, int startIndex, int count, CompareOptions options)
unsafe bool IsPrefix(ReadOnlySpan< char > source, ReadOnlySpan< char > prefix, CompareOptions options, out int matchLength)
int LastIndexOf(string source, string value, int startIndex, int count)
int Compare(string? string1, int offset1, int length1, string? string2, int offset2, int length2)
bool IsSuffix(string source, string suffix, CompareOptions options)
void InitSort(CultureInfo culture)
unsafe int NlsIndexOfCore(ReadOnlySpan< char > source, ReadOnlySpan< char > target, CompareOptions options, int *matchLengthPtr, bool fromBeginning)
int GetSortKeyLength(ReadOnlySpan< char > source, CompareOptions options=CompareOptions.None)
int IndexOf(string source, char value, int startIndex, int count)
CompareInfo(CultureInfo culture)
unsafe int IcuGetSortKey(ReadOnlySpan< char > source, Span< byte > destination, CompareOptions options)
unsafe bool IcuEndsWith(ReadOnlySpan< char > source, ReadOnlySpan< char > suffix, CompareOptions options, int *matchLengthPtr)
unsafe int LastIndexOf(ReadOnlySpan< char > source, ReadOnlySpan< char > value, CompareOptions options=CompareOptions.None)
int LastIndexOf(string source, string value, CompareOptions options)
static int InvariantGetSortKey(ReadOnlySpan< char > source, Span< byte > destination, CompareOptions options)
static bool IsSortable(string text)
int IndexOf(string source, string value, int startIndex)
unsafe int IndexOf(ReadOnlySpan< char > source, ReadOnlySpan< char > value, int *matchLengthPtr, CompareOptions options, bool fromBeginning)
int LastIndexOf(string source, char value, int startIndex, int count, CompareOptions options)
static bool IsCustomCultureId(int cultureId)
static CultureInfo InvariantCulture
static CultureInfo GetCultureInfo(int culture)
static int CompareStringIgnoreCase(ref char strA, int lengthA, ref char strB, int lengthB)
static int IndexOfOrdinalIgnoreCase(ReadOnlySpan< char > source, ReadOnlySpan< char > value)
Definition Ordinal.cs:151
static int LastIndexOfOrdinalIgnoreCase(ReadOnlySpan< char > source, ReadOnlySpan< char > value)
Definition Ordinal.cs:172
static int CompareStringIgnoreCase(ref char strA, int lengthA, ref char strB, int lengthB)
Definition Ordinal.cs:8
static void ToUpper(char h, char l, out char hr, out char lr)
static ulong DefaultSeed
Definition Marvin.cs:13
static int ComputeHash32(ReadOnlySpan< byte > data, ulong seed)
Definition Marvin.cs:17
static byte Min(byte val1, byte val2)
Definition Math.cs:912
virtual Assembly Assembly
Definition Module.cs:15
static string Arg_ExternalException
Definition SR.cs:154
static string Argument_OnlyMscorlib
Definition SR.cs:836
static string ArgumentOutOfRange_NeedPosNum
Definition SR.cs:20
static string Argument_CompareOptionOrdinal
Definition SR.cs:524
static string ArgumentOutOfRange_GetByteCountOverflow
Definition SR.cs:88
static string Argument_InvalidFlag
Definition SR.cs:688
static string Argument_CustomCultureCannotBePassedByNumber
Definition SR.cs:554
static string ArgumentOutOfRange_OffsetLength
Definition SR.cs:1084
Definition SR.cs:7
static void ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count()
static void ThrowArgumentOutOfRangeException(System.ExceptionArgument argument)
static void ThrowArgumentNullException(string name)
static void ThrowArgumentException(ExceptionResource resource)
static void ThrowArgumentException_DestinationTooShort()
static int Size
Definition IntPtr.cs:21
static readonly IntPtr Zero
Definition IntPtr.cs:18
static OperationStatus DecodeFromUtf16(ReadOnlySpan< char > source, out Rune result, out int charsConsumed)
Definition Rune.cs:168
static UnicodeCategory GetUnicodeCategory(Rune value)
Definition Rune.cs:662