4 ms·
Took his advice and opened up a random angular source file. Found this fun, little snippet: // String#toLowerCase and String#toUpperCase don't produce correc
by gizzlon 13y ago
Took his advice and opened up a random angular source file. Found this fun, little snippet:
// String#toLowerCase and String#toUpperCase don't produce correct results in browsers with Turkish
// locale, for this reason we need to detect this case and redefine lowercase/uppercase methods
// with correct but slower alternatives.
if ('i' !== 'I'.toLowerCase()) {
lowercase = manualLowercase;
uppercase = manualUppercase;
}
Looks like Angular is more battle-tested than I would expect..
- acdha 13y agoThat's actually wrong unless that i/I code is strictly internal data which is never shown to a human. Where was the snippet from?
- gizzlon 13y agoWhy is that? https://github.com/angular/angular.js/blob/master/src/Angular.js#L41 https://github.com/angular/angular.js/blob/master/src/Angula...
- acdha 13y agoIn Turkish, "i" uppercases to "İ" (note the dot) - there's a separate undotted lowercase "ı" which becomes "I": http://www.i18nguy.com/unicode/turkish-i18n.html http://www.i18nguy.com/unicode/turkish-i18n.html So basically if your goal is for "i".upperCase() to produce something which goes to another program (e.g. an API call), the Angular code is correct. If it's going to be displayed to humans, it's wrong. The documentation at http://docs.angularjs.org/api/angular.uppercase http://docs.angularjs.org/api/angular.uppercase should probably specify that this cannot be used for user content.
- iso8859-1 13y agoIt's a weird comment because the definition of "correct" is not specified. Is it a workaround for a bug in Unicode or a bug in its implementation?
- deleted 13y ago[deleted]
- taeric 13y agoThe bug is developers not realizing that a capital "i" is not universally constant. That is, there is no bug in either unicode nor implementation. Just something highly non-obvious to the rest of the world.
- deleted 13y ago[deleted]
- numlocked 13y agoAhh, Turkey strikes again! The Turkish locale is notoriously difficult to handle for a variety of reasons. One of my colleagues wrote an excellent post about the different ways that Turkish conventions can break your code: http://www.moserware.com/2008/02/does-your-code-pass-turkey-test.html http://www.moserware.com/2008/02/does-your-code-pass-turkey-... This seems to be yet another one!
- tobinfricke 13y agoThe date format and digits separators issues are not at all specific to Turkey. The only thing uniquely Turkish in the "Turkish test" is the treatment of the case of "i" with and without a dot.