String.Compare() with Hungarian CultureInfo works not correct for specific strings:
if (0 == String.Compare(@"ny", @"nY", true, new CultureInfo("hu-HU")))
Console.WriteLine("Equal");
else
Console.WriteLine("Not equal");
Of course I suppose to get "Equal" answer, but it's not. If I change the string it works properly (for example for "abc" and "ABC" it prints "Equal") It seems a problem with specific symbols.
What would you expect? In Hungarian, "ny" is considered one letter. It can be written like "ny", "Ny", or "NY". But never "nY". This works as expected:
var hu = new CultureInfo("hu-HU");
Console.WriteLine(String.Compare("Ny", "NY", true, hu));
Console.WriteLine(String.Compare("ny", "NY", true, hu));
Console.WriteLine(String.Compare("ny", "Ny", true, hu));
In Hungarian, they don't have a letter "y" except in foreign words and some names. But when you say "nY"
, there's no possibility that this could be the "ny" letter. So maybe .NET treats it as two letters.
Does anyone know Hungarian language well? It could be interesting to hear their opinion. But I'm pretty sure the string "nY" could never appear in "natural" Hungarian.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With