This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
Copy pathTextInfo.Unix.cs
57 lines (47 loc) · 1.92 KB
/
TextInfo.Unix.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
namespace System.Globalization
{
public partial class TextInfo
{
private Tristate _needsTurkishCasing = Tristate.NotInitialized;
private void FinishInitialization() { }
// -----------------------------
// ---- PAL layer ends here ----
// -----------------------------
private bool NeedsTurkishCasing(string localeName)
{
Debug.Assert(localeName != null);
return CultureInfo.GetCultureInfo(localeName).CompareInfo.Compare("\u0131", "I", CompareOptions.IgnoreCase) == 0;
}
private bool IsInvariant { get { return _cultureName.Length == 0; } }
internal unsafe void ChangeCase(char* src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bToUpper)
{
Debug.Assert(!GlobalizationMode.Invariant);
if (IsInvariant)
{
Interop.Globalization.ChangeCaseInvariant(src, srcLen, dstBuffer, dstBufferCapacity, bToUpper);
}
else
{
if (_needsTurkishCasing == Tristate.NotInitialized)
{
_needsTurkishCasing = NeedsTurkishCasing(_textInfoName) ? Tristate.True : Tristate.False;
}
if (_needsTurkishCasing == Tristate.True)
{
Interop.Globalization.ChangeCaseTurkish(src, srcLen, dstBuffer, dstBufferCapacity, bToUpper);
}
else
{
Interop.Globalization.ChangeCase(src, srcLen, dstBuffer, dstBufferCapacity, bToUpper);
}
}
}
}
}