问题
I have the following code:
string firstMicro = "aa \u00b5 bb";
string secondMicro = "aa \u03bc bb";
Assert.IsFalse(firstMicro == secondMicro);
string upperFirstMicro = firstMicro.ToUpper();
string upperSecondMicro = secondMicro.ToUpper();
Assert.IsFalse(upperFirstMicro == upperSecondMicro);
In my case, the first test passes (obviously, both strings are different), but in second case, the test fails because both texts are identical ($AA M BB). I admit that in one of the cases I should have used CultureInfo - but at least in the first case (the micro sign from ASCII code) should have stayed the same ... Can someone help me understand why is this happening?
Aparently, there is another thread here - How to correctly uppercase Greek words in .NET?, but there is no obvious answer ...
Thanks. D.
回答1:
Some lowercase letters have the same uppercase equivalent. Sorry, but that's how Unicode is defined.
For example, as you can see in the official UnicodeData.txt, both U+0069 (i)
and U+0131 (ı)
have U+0049 (I)
for uppercase.
What is the exact problem you're having? Maybe we can help.
回答2:
A microsecond is still a µSEC after upper-casing. Having it upcased to MSEC would fatally alter its meaning. Which is why there are two codepoints for the glyph.
来源:https://stackoverflow.com/questions/9616984/net-micro-%c2%b5-greek-letter-uppercase-issue