lower case of turkish character dotted i

江枫思渺然 提交于 2019-12-18 05:01:41

问题


In Java 6,

System.out.println(String.valueOf('\u0130').toLowerCase());

prints i (u0069), but in Java 7 it prints i with double dots (u0069 u0307).

I understand it is a Turkish character, but how do I make Java 7 print the same output as v6 using this code?

System.out.println(inputText.toLowerCase());

Also make sure that the code can handle international text without hardcoding the toLowerCase function to use only Turkish locale.


回答1:


There is a quite detailed blog post about this i toLowerCase problem


Let me try to summarize the essential parts:

In Java 7 this method has indeed changed and handles this char differently than Java 6. The following code was added:

} else if (srcChar == '\u0130') { // LATIN CAPITAL LETTER I DOT
    lowerChar = Character.ERROR;
}

==> This change results in the following way:

Basically the end result of this change is that for this specific case (the upper-case dotted I), Java 7 now consults a special Unicode character database (http://www.unicode.org/Public/UNIDATA/SpecialCasing.txt), which provides data on complex case-mappings. Looking at this file you can see several lines for the upper-case dotted I:

CODE       LOWER   TITLE   UPPER  LANGUAGE
0130;  0069 0307;   0130;   0130;
0130;  0069;        0130;   0130;       tr;
0130;  0069;        0130;   0130;       az;


来源:https://stackoverflow.com/questions/23524231/lower-case-of-turkish-character-dotted-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!