4 ms·
True, but that issue has been existing for the past decades already. toLower(toUpper(a)) != a len(toLower(toUpper(a))) != a If your code assumes any o
by kuschku 8y ago
True, but that issue has been existing for the past decades already.
toLower(toUpper(a)) != a
len(toLower(toUpper(a))) != a
If your code assumes any of this, it already was broken
- komali2 8y agoOh wait wtf, why
- nneonneo 8y agoCase 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.
- contravariant 8y agoYou'd assume the somewhat weaker properties of: toLower(toUpper(a)) == toLower(a) toLower(toLower(a)) == toLower(a) should work though, with German even that is not guaranteed unless you really spend a lot of time figuring out when to convert SS to ß. I suppose making toLower convert ß to ss would avoid that particular problem, but I'm not sure the Germans would agree with that one (which is why I said no nice solution exists). At the very least it looks like you need a different toLower for style purposes than one for string comparison, unless someone can come up with a string where replacing ß with ss changes the meaning (or some equivalent to this), in which case there's no hope.
- fhars 8y ago> I suppose making toLower convert ß to ss would avoid that particular problem But that function would not be toLower(), it would be toSwiss() > unless someone can come up with a string where replacing ß with ss changes the meaning "Er trinkt in Maßen" - He drinks with moderation. "Er trinkt in Massen" - He drinks huge amounts. The pronounciation is different, too, a vowel before "ß" is long, before "ss" short.
- contravariant 8y agoWell, there goes any hope of a sensible case-insensitive way to compare strings in German. Unless you can figure out which of those two should correspond to "ER TRINKT IN MASSEN".
- NihilumExNil 8y agoI think drinking too much is why we are having this problem in the first place, so maybe people should just stop it. You'd end up with Maßßen and Maszen eventually. Ich geh dann mal zum Arz, mir jezt ein attezt holen. Da wird man doch bekloppt.
- NihilumExNil 8y agoI maintain that ss is a legitimate substitute in standard German orthography, just as ae for ä etc. not only because I can't be arsed to switch key layouts, but because ß is a useless character. If you compare Fuß, Ruß and Mus; Muss and Bus, Plus; Museeum and Muster. It is derived from a ligature, which is not any less confusing between ss and sz. So Buße implies it was once written Busse (or Busze). Add to that the phonetic difference between jetzt, jezt, and Arzt, is rather ridiculous, I mean, what do we have the c for? We rather standardize an extra letter and use c chiefly in ch and sch, but why? Ich habe da so meine Cweifel, ehh Tsweivel, eh ... ach lassen wir dass.