0

I have faced issue that javascript function toLowerCase() converts big " İ " letter differently than expected in Azeri language. Here is link screen shot of what I mean. https://www.dropbox.com/s/k7w0vfla00ymp30/Screen%20Shot%202019-01-16%20at%204.16.10%20PM.png?dl=0

var str = "İsveç kronu"; 
var n = str.toLowerCase();
console.log(n);

Expected result is small " i " but it returns " i̇ " with two dots on top of it. But here also editor makes it not able to bee seen. Therefore I added result image.

WebMan
  • 360
  • 4
  • 14
  • 1
    Did you try `toLocaleLowerCase()`? – freedomn-m Jan 16 '19 at 12:45
  • 4
    Possible duplicate of [Difference between toLocaleLowerCase() and toLowerCase()](https://stackoverflow.com/questions/34283414/difference-between-tolocalelowercase-and-tolowercase) – freedomn-m Jan 16 '19 at 12:45
  • 1
    What is interesting `n.codePointAt(0)` return 105 (which supposed to be "Latin Small Letter I" i ) and `n.codePointAt(1)` returns 775 which is "COMBINING DOT ABOVE" http://www.fileformat.info/info/unicode/char/0307/index.htm – Moti Korets Jan 16 '19 at 12:53
  • What browser are you using? Chrome+IE11 handled `toLowerCase` while IEdge gave something different from your screenshot. All 3 worked with `toLocaleLowerCase("az", str);` – freedomn-m Jan 16 '19 at 12:58
  • @freedomn-m not tried it. Now understood differences by reading your duplicate tag on such situations. I have tried both Chrome and Firefox Quantum and the same results. But it is interesting that why developer decided to create different functions. Could be only one function to be able to do both at once. I guess performance may be issue. – WebMan Jan 16 '19 at 13:36
  • Legacy. Most of these functions existed in one form or another *long* before anyone thought of using different language characters. eg in the ASCII character set, `c=c.toUpperCase()` is just `c|=0x20`. So for backward-compatibility, there are numerous `Locale` versions of anything that manipulates text. – freedomn-m Jan 16 '19 at 15:19

0 Answers0