I was trying my hand over System.Gloablization in a small desktop app. I am a bit confused about the additional control CultureInfo.Compare()
has to offer than using String.Compare()
method and its overloads.
Let's say I have two strings
String s1 = "\u3057\u3093\u304B\u3093\u305b\u3093"; //some Japanese text in Unicode
String s2 = "\u30b7\u3043\u30ab\u30f3\u30bb\u30f3"; //Some Japanese text in Unicode
CultureInfo ci = new CultureInfo("ja-JP");
String.Compare
has several overloads, out of which currently I would use
String.Compare(String strA, String strB, CultureInfo culture, CompareOptions options)
(where CompareOptions is an Enumerated type)
However, I could also use:
CompareInfo compareInfo = CompareInfo.GetCompareInfo("ja-JP");
compareInfo.Compare(String strA, String strB, CompareOptions options);
for the same purpose.
How does the CultureInfo's CompareInfo object provide more control when handling such situation in globalization such as Japanese text for eg: CompareOptions.IgnoreKanaType (where Kana is a second form of Japanese which can be ignored from the string using CompareOptions enumaerated type).