string - Is Javascript's toUpperCase() language safe? -


will javascript's string prototype method touppercase() deliver naturally expected result in every utf-8-supported language/charset?

i've tried simplified chinese, south korean, tamil, japanese , cyrillic , results seemed reasonable far. can rely on method being language-safe?

example:

  "イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス".touppercase() > "イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス" 

edit: @quentin pointed out, there string.prototype.tolocaleuppercase() "safer" use, have support ie 8 , above, webkit-based browsers. since part of ecmascript 3 standard, should available on browsers, right?

does know of cases using delivers naturally unexpected results?

what expect?

javascript's touppercase() method supposed use "locale invariant upper case mapping" defined unicode standard. so, basically, "i".touppercase() supposed i in cases. in cases locale invariant upper case mapping consists of multiple letters, browsers not upper case them correctly, example "ß".touppercase() not ss.

also, there locales have different uppercase rules rest of world, notable example being turkish, uppercase version of i İ (and vice versa) , lowercase version of i ı (and vice versa).

if want behaviour, need browser set turkish locale, , have use tolocaleuppercase() method.

also note writing systems have third case, "title case", applied first letter of word when want "capitalize" it. defined unicode standard (for example, title case of ligature njis Nj while upper case NJ), (as far know) not available javascript. therefore if try capitalize word using substring , touppercase, expect wrong in rare cases.


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -