Consider this comparison:
String a = "\u00C4"; // "LATIN CAPITAL LETTER A WITH DIAERESIS"
String b = "\u0041\u0308"; // "LATIN CAPITAL LETTER A" and "COMBINING DIAERESIS"
Comparing these in C# Danish cultu开发者_Python百科re, returns false:
Thread.CurrentThread.CurrentCulture = new CultureInfo("da-DK", false);
Console.WriteLine(a.Equals(b, StringComparison.CurrentCulture)); // false
Comparing these in Java Danish locale, returns true:
System.out.println(Collator.getInstance(new Locale("Danish (Denmark)").equals(a,b)); // true
I have listed all locales/cultures in both environments and have confirmed that the right ones are selected. Am I missing something? What's with the difference?
I can't reproduce your results using .NET 4:
using System;
using System.Globalization;
using System.Threading;
public class Test
{
static void Main()
{
String a = "\u00C4";
String b = "\u0041\u0308";
Thread.CurrentThread.CurrentCulture = new CultureInfo("da-DK", false);
Console.WriteLine(a.Equals(b, StringComparison.CurrentCulture));
}
}
That program prints "True" for me. Does the exact same program print "False" for you?
精彩评论