简体   繁体   English

如何将unicode字符打印成字符串?

[英]How to print unicode character into string?

Getting invalid unicode error with below code使用以下代码获取invalid unicode错误

Uniocde want to print: unicode:0x16 Uniocde 想打印: unicode:0x16

PrintWriter pw = new PrintWriter(System.out, true);
char aa = "\u0x16";
pw.println(aa);

What's wrong happening here ?这里发生了什么问题?

\\u0x16 is not a valid unicode character reference. \\u0x16不是有效的 unicode 字符引用。 There should be 4 hexadecimal digits (numbers 0-9 letters af) after \\u\u003c/code> - the "x" is not valid. \\u\u003c/code>之后应该有 4 个十六进制数字(数字 0-9 个字母 af) - “x”无效。

If you meant to use the character U+0016, it's written as \ :如果您打算使用字符 U+0016,则将其写为\

char aa = '\u0016';

The following is equivalent, but it uses an integer constant rather than a character constant.以下是等效的,但它使用整数常量而不是字符常量。

char aa = 0x16;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM