3 ms·
Case changes are locale-sensitive. For example, if your locale is Turkish, toUpper(“i”) is “İ”, the Turkish dotted-I. Meanwhile, toLower(“I”) is “ı”, the dotles
by nneonneo 8y ago
Case changes are locale-sensitive. For example, if your locale is Turkish, toUpper(“i”) is “İ”, the Turkish dotted-I. Meanwhile, toLower(“I”) is “ı”, the dotless I.
But now, if you don’t have your locale set to Turkish, then you have
toUpper(“ı”) = “I”, toLower(“I”) = “i”
so the character does not round trip.
- tedunangst 8y agoThat doesn't explain why upper lower conversion shouldn't round trip within one locale.
- duckerude 8y agoAs an example, the Greek letter sigma has two lowercase forms, depending on whether it's at the end of a word. So 'ς'.upper().lower() == 'σ', even though all three characters are ordinary Greek letters you could even find within a single word.
- princekolt 8y agoadds to personal notes: Never accept a job that involves manually dealing with locales
- rspeer 8y agoGood note, but the fact that ς doesn't round trip isn't locale-dependent.
- tedunangst 8y agoThanks. That's a much better example.