在Java 6中,
System.out.println(String.valueOf('\u0130').toLowerCase());打印i(u0069),但是在Java 7中,它用双点(u0069 u0307)打印i.
prints i (u0069), but in Java 7 it prints i with double dots (u0069 u0307).
我知道这是土耳其语字符,但是如何使用此代码使Java 7输出与v6相同的输出?
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());还要确保代码可以处理国际文本,而无需对toLowerCase函数进行硬编码以仅使用土耳其语区域设置.
Also make sure that the code can handle international text without hardcoding the toLowerCase function to use only Turkish locale.
推荐答案有一个非常详细的有关此i toLowerCase问题的博客文章
让我尝试总结以下重要部分:
Let me try to summarize the essential parts:
在Java 7中,此方法的确发生了变化,并且处理此字符的方式与Java 6不同.添加了以下代码:
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:
基本上,此更改的最终结果是针对此特定情况 (大写的虚线I),Java 7现在使用特殊的Unicode 角色数据库 ( www.unicode/Public/UNIDATA/SpecialCasing.txt), 提供有关复杂案例映射的数据.查看此文件,您可以 看到几行大写的虚线I:
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 (www.unicode/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;
更多推荐
土耳其字符的小写字母点缀我
发布评论