SHOW:
|
|
- or go back to the newest paste.
| 1 | using System; | |
| 2 | using System.Collections.Generic; | |
| 3 | using System.Linq; | |
| 4 | using System.Globalization; | |
| 5 | using System.Text; | |
| 6 | - | |
| 6 | + | |
| 7 | class CollationTest | |
| 8 | {
| |
| 9 | class TestChar | |
| 10 | {
| |
| 11 | public char Value { get; set; }
| |
| 12 | public string Name { get; set; }
| |
| 13 | public override string ToString() | |
| 14 | {
| |
| 15 | return String.Format("{0} '{1}' ('\\u{2:X4}')", Name, Value, (int)Value);
| |
| 16 | } | |
| 17 | } | |
| 18 | static void Main(string[] args) | |
| 19 | {
| |
| 20 | - | string cultureName = args.Length >= 1 ? args[0] : "zh-Hans"; |
| 20 | + | string cultureName = |
| 21 | (args.Length == 0) ? "zh-Hans" : | |
| 22 | (args[0] == "invariant") ? "" : | |
| 23 | args[0]; | |
| 24 | - | new TestChar { Value = '\u5DE7', Name = "qiǎo " },
|
| 24 | + | |
| 25 | - | new TestChar { Value = '\u8EAB', Name = "shēn " },
|
| 25 | + | |
| 26 | new TestChar { Value = '\u5999', Name = "miào" },
| |
| 27 | - | new TestChar { Value = '\u4EE5', Name = "yǐ " },
|
| 27 | + | new TestChar { Value = '\u5DE7', Name = "qiao " },
|
| 28 | new TestChar { Value = '\u8EAB', Name = "shen " },
| |
| 29 | new TestChar { Value = '\u793A', Name = "shì " },
| |
| 30 | new TestChar { Value = '\u4EE5', Name = "yi " },
| |
| 31 | - | var cinfo = new CultureInfo(args[0]); |
| 31 | + | |
| 32 | new TestChar { Value = '\u4F5C', Name = "zuò " },
| |
| 33 | }; | |
| 34 | var cinfo = new CultureInfo(cultureName); | |
| 35 | Console.WriteLine("{0}: {1}", cinfo.Name, cinfo.DisplayName);
| |
| 36 | chars.Sort((a,b)=>String.Compare(a.Value.ToString(),b.Value.ToString(),true,cinfo)); | |
| 37 | foreach (var item in chars) | |
| 38 | {
| |
| 39 | Console.WriteLine(item); | |
| 40 | } | |
| 41 | } | |
| 42 | } |