以下代码出现无效的 unicode
错误
Uniocde 要打印:unicode:0x16
PrintWriter pw = new PrintWriter(System.out, true);
char aa = "\u0x16";
pw.println(aa);
这里发生了什么问题?
最佳答案
\u0x16
不是有效的 unicode 字符引用。 \u
之后应该有 4 个十六进制数字(数字 0-9 字母 a-f) - “x”无效。
如果您打算使用字符 U+0016,则将其写为 \u0016
:
char aa = '\u0016';
以下内容是等效的,但它使用整数常量而不是字符常量。
char aa = 0x16;
关于java - 如何将 unicode 字符打印到字符串中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60970499/