Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Globalization;
- using System.Text;
- class CollationTest
- {
- class TestChar
- {
- public char Value { get; set; }
- public string Name { get; set; }
- public override string ToString()
- {
- return String.Format("{0} '{1}' ('\\u{2:X4}')", Name, Value, (int)Value);
- }
- }
- static void Main(string[] args)
- {
- string cultureName =
- (args.Length == 0) ? "zh-Hans" :
- (args[0] == "invariant") ? "" :
- args[0];
- var chars = new List<TestChar> {
- new TestChar { Value = '\u8303', Name = "fan" },
- new TestChar { Value = '\u5999', Name = "miào" },
- new TestChar { Value = '\u5DE7', Name = "qiao " },
- new TestChar { Value = '\u8EAB', Name = "shen " },
- new TestChar { Value = '\u793A', Name = "shì " },
- new TestChar { Value = '\u4EE5', Name = "yi " },
- new TestChar { Value = '\u5219', Name = "zé " },
- new TestChar { Value = '\u4F5C', Name = "zuò " },
- };
- var cinfo = new CultureInfo(cultureName);
- Console.WriteLine("{0}: {1}", cinfo.Name, cinfo.DisplayName);
- chars.Sort((a,b)=>String.Compare(a.Value.ToString(),b.Value.ToString(),true,cinfo));
- foreach (var item in chars)
- {
- Console.WriteLine(item);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement