显示Unicode时出错

时间:2013-08-11 20:52:44

标签: java unicode

我是使用unicode的新手,我目前无法显示我从这位翻译中收到的一些中文文字:http://www.chinese-tools.com/tools/converter-unicode.html

我在示例中成功使用了unicode,当时文本只是一个像这样的数字:\ u0050但是,我显示的文字更复杂,看起来像这样:中国的;当我在它之前放置“\ u”时,我收到一个编译时错误,指出“无效的Unicode”。

全线是:        System.out.println("\u中国的");

1 个答案:

答案 0 :(得分:0)

我修正了错误,首先将翻译网站作为翻译返回的内容转换为hexee作为tripleee推荐。然后我创建了一个字符串。

String foreignWord = ("\u4e2d" + "\u56fd" + "\u7684");
String foreignWordConverted = (new String(foreignWord.getBytes("UTF-8")));
System.out.println( foreignWordConverted );