【发布时间】:2013-07-04 12:23:47
【问题描述】:
我正在使用支持我的语言乌尔都语的 Windows XP。 IDE 是 JCreator。我面临的问题是,对于我的项目来说,如果我能够直接在我的代码中使用乌尔都语文本将非常容易,但不幸的是它不起作用。任何帮助将不胜感激。
//urWord 是方法参数中的任意单词
String s = "\u0628\u0627\u067e";
String trial = "باپ";
int comparison = s.compareTo(urWord);
System.out.println (urWord);
System.out.println (comparison);
//works perfectly
if(s.equals(urWord)){
System.out.println ("Strings are equal");
}
//does not work
if(s.equals(trial)){
System.out.println ("Strings are equal");
}
【问题讨论】:
-
您的代码对我有用,s 等于试用,如果我通过命令行参数将乌尔都语单词传递给
urWord,它也可以工作。一切都是平等的。因此,您的 IDE、操作系统或您从哪里获得urWord很可能存在编码问题。 -
在已经用 utf-8 编码的源代码中使用 utf-8 文字怎么样? utf8everywhere.org
标签: java string unicode comparison