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

◆ IcuNormalize()

static unsafe string System.Globalization.Normalization.IcuNormalize ( string strInput,
NormalizationForm normalizationForm )
inlinestaticprivate

Definition at line 50 of file Normalization.cs.

51 {
52 ValidateArguments(strInput, normalizationForm);
53 char[] array = null;
54 try
55 {
56 Span<char> span = ((strInput.Length > 512) ? ((Span<char>)(array = ArrayPool<char>.Shared.Rent(strInput.Length))) : stackalloc char[512]);
57 Span<char> span2 = span;
58 for (int i = 0; i < 2; i++)
59 {
60 int num;
61 fixed (char* src = strInput)
62 {
63 fixed (char* dstBuffer = &MemoryMarshal.GetReference(span2))
64 {
65 num = Interop.Globalization.NormalizeString(normalizationForm, src, strInput.Length, dstBuffer, span2.Length);
66 }
67 }
68 if (num == -1)
69 {
70 throw new ArgumentException(SR.Argument_InvalidCharSequenceNoIndex, "strInput");
71 }
72 if (num <= span2.Length)
73 {
74 ReadOnlySpan<char> readOnlySpan = span2.Slice(0, num);
75 return readOnlySpan.SequenceEqual(strInput) ? strInput : new string(readOnlySpan);
76 }
77 if (i == 0)
78 {
79 if (array != null)
80 {
81 char[] array2 = array;
82 array = null;
83 ArrayPool<char>.Shared.Return(array2);
84 }
85 span2 = (array = ArrayPool<char>.Shared.Rent(num));
86 }
87 }
88 throw new ArgumentException(SR.Argument_InvalidCharSequenceNoIndex, "strInput");
89 }
90 finally
91 {
92 if (array != null)
93 {
95 }
96 }
97 }
static unsafe int NormalizeString(NormalizationForm normalizationForm, char *src, int srcLen, char *dstBuffer, int dstBufferCapacity)
static ArrayPool< T > Shared
Definition ArrayPool.cs:7
static void ValidateArguments(string strInput, NormalizationForm normalizationForm)

References System.SR.Argument_InvalidCharSequenceNoIndex, System.array, System.Span< T >.Length, Interop.Globalization.NormalizeString(), System.Buffers.ArrayPool< T >.Shared, System.Span< T >.Slice(), and System.Globalization.Normalization.ValidateArguments().

Referenced by System.Globalization.Normalization.Normalize().