|
| 1 | +'<snippet1> |
| 2 | +' Sample for String.ToLower(CultureInfo) |
| 3 | +Imports System.Globalization |
| 4 | + |
| 5 | +Class Sample |
| 6 | + Public Shared Sub Main() |
| 7 | + Dim str1 As [String] = "INDIGO" |
| 8 | + ' str2 = str1, except each 'I' is '\u0130' (Unicode LATIN CAPITAL I WITH DOT ABOVE). |
| 9 | + Dim str2 As New [String](New [Char]() {ChrW(&H0130), "N"c, "D"c, ChrW(&H0130), "G"c, "O"c}) |
| 10 | + Dim str3, str4 As [String] |
| 11 | + |
| 12 | + Console.WriteLine() |
| 13 | + Console.WriteLine("str1 = '{0}'", str1) |
| 14 | + |
| 15 | + Console.WriteLine() |
| 16 | + Console.WriteLine("str1 is {0} to str2.", _ |
| 17 | + IIf(0 = [String].CompareOrdinal(str1, str2), "equal", "not equal")) |
| 18 | + CodePoints("str1", str1) |
| 19 | + CodePoints("str2", str2) |
| 20 | + |
| 21 | + Console.WriteLine() |
| 22 | + ' str3 is a lower case copy of str2, using English-United States culture. |
| 23 | + Console.WriteLine("str3 = Lower case copy of str2 using English-United States culture.") |
| 24 | + str3 = str2.ToLower(New CultureInfo("en-US", False)) |
| 25 | + |
| 26 | + ' str4 is a lower case copy of str2, using Turkish-Turkey culture. |
| 27 | + Console.WriteLine("str4 = Lower case copy of str2 using Turkish-Turkey culture.") |
| 28 | + str4 = str2.ToLower(New CultureInfo("tr-TR", False)) |
| 29 | + |
| 30 | + ' Compare the code points in str3 and str4. |
| 31 | + Console.WriteLine() |
| 32 | + Console.WriteLine("str3 is {0} to str4.", _ |
| 33 | + IIf(0 = [String].CompareOrdinal(str3, str4), "equal", "not equal")) |
| 34 | + CodePoints("str3", str3) |
| 35 | + CodePoints("str4", str4) |
| 36 | + End Sub |
| 37 | + |
| 38 | + Public Shared Sub CodePoints(title As [String], s As [String]) |
| 39 | + Console.Write("{0}The code points in {1} are: {0}", Environment.NewLine, title) |
| 40 | + Dim c As Char |
| 41 | + For Each c In s |
| 42 | + Console.Write("{0:x4} ", AscW(c)) |
| 43 | + Next c |
| 44 | + Console.WriteLine() |
| 45 | + End Sub |
| 46 | +End Class |
| 47 | +' |
| 48 | +'str1 = 'INDIGO' |
| 49 | +' |
| 50 | +'str1 is not equal to str2. |
| 51 | +' |
| 52 | +'The code points in str1 are: |
| 53 | +'0049 004e 0044 0049 0047 004f |
| 54 | +' |
| 55 | +'The code points in str2 are: |
| 56 | +'0130 004e 0044 0130 0047 004f |
| 57 | +' |
| 58 | +'str3 = Lower case copy of str2 using English-United States culture. |
| 59 | +'str4 = Lower case copy of str2 using Turkish-Turkey culture. |
| 60 | +' |
| 61 | +'str3 is equal to str4. |
| 62 | +' |
| 63 | +'The code points in str3 are: |
| 64 | +'0069 006e 0064 0069 0067 006f |
| 65 | +' |
| 66 | +'The code points in str4 are: |
| 67 | +'0069 006e 0064 0069 0067 006f |
| 68 | +'</snippet1> |
0 commit comments