4 ms·
I also doubt the validity of the upper-casing, it feels like in an internationalization/localization context, converting a string to all upper case is not a val
by unwind 13y ago
I also doubt the validity of the upper-casing, it feels like in an internationalization/localization context, converting a string to all upper case is not a valid thing to be doing.
Not all languages (or even characters) have a well-defined upper-case versions of their glyphs.
Even if they all did, I would expect the interpretation by a (human) reader to vary culturally.
- judofyr 13y agoThe Unicode standard includes uppercase rules. If you're already representing strings using Unicode codepoints, why not follow the whole Unicode standard? EDIT: And yes, different languages can have different uppercasing rules. There's still a standard: https://github.com/lang/unicode_utils/blob/master/data/CaseFolding.txt https://github.com/lang/unicode_utils/blob/master/data/CaseF...
- unwind 13y agoThanks, I was not aware of that. I guess "uppercase this string" goes from being a tiny loop to a big ... thing based on a lot of hardcoded knowledge, which in turn might indicate that it's not a very simple operation any more.
- XorNot 13y agoThe usual goal is to apply a consistent transform though, to smooth out interpretation differences - i.e. when looking for command input I either lowercase or uppercase things to smooth over the fact that "yes" "YES" "Yes" are all completely valid ways of saying the same thing with those characters. If there's only one way of expressing the thing - i.e. a single chinese character - then it would be valid to do nothing. It's just in english "y" and "Y" might change context, but as far as computer input is generally concerned they are the same thing.
- TorKlingberg 13y agoFor that use case it is better to compare case insensitively with "yes" instead of converting the input to lower case first.
- zokier 13y agoHow do you do case-insensitive comparison without normalizing the case of the operands?
- gnaritas 13y agoMost string compare routines in the library offer a case insensitive compare option already, you don't have to normalize it.
- asveikau 13y agoIf you can compare case-insensitively then you (or the library you call into) must be aware of case and you face the exact same problems. It's a pretty good thought exercise to attempt writing your own Unicode-aware case insensitive string compare. A lot of people call into libraries for this stuff without realizing how complex the problem gets.
- ianburrell 13y agoTo compare strings case-insensitively, you want case-folding instead of lowercase or uppercase. Unicode defines case-folding for comparing strings. There are enough complexities with case, like characters that don't have other case or multiple mappings, that it can't be correctly used for comparison.
- DougBTX 13y agoHere are the Unicode rules, which do consider localization: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt It would be interesting to know how often these rules are actually used though...
- russellsprouts 13y agoMany designers use abbr{ text-transform:lowercase; font-variant:small-caps; letter-spacing:.1em; } To make acronyms like HTML and CSS look better on the page. To support i18n, HTML allows setting the language on a per-document or even per-element basis. That way the upper- or lower-casing can be done following the rules of the language.