开发者

display the unicode value in the java screen

how to display non english words 开发者_Python百科with unicode in java?

"\u0905\u092E\u0940\u0924\u093E\u092A" i have to display this ib Hindi?


Just have it in a String and display it. You only need to use the proper encoding in the display component/console. UTF-8 should suffice.

System.out.println("\u0905\u092E\u0940\u0924\u093E\u092A");

This prints अमीताप in my Eclipse environment which is configured to use UTF-8 in its console.

Edit: this ain't going to work in for example the Windows command console, because it by default doesn't use UTF-8 nor has a font which covers those codepoints. If you're actually using Eclipse, then you can set the Workspace encoding in its preferences by General > Workspace > Text file encoding.

Further on, anywhere where an Java API can take the character encoding as extra argument, then you need to make use of it and set it to UTF-8. Otherwise the platform default encoding will be used, which may be ISO-8859-1 or cp1252, which is incorrect for those characters. If you for example want to write this String to some OutputStream, then you need to construct an OutputStreamWriter where in you pass UTF-8 as 2nd constructor argument. You may find this article useful as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜