Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
741 views
Welcome To Ask or Share your Answers For Others

1 Answer

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;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...