我想用 Java 编写 unicode 文字 U+10428。 http://www.marathon-studios.com/unicode/U10428/Deseret_Small_Letter_Long_I
我尝试使用“\u10428”,但无法编译。
最佳答案
由于 Java 在人们认为 64K 对每个人都足够时(以前从哪里听说过这样的消息?)开始使用 UCS-2,后来升级到 UTF-16。
但他们从来没有为 BMP 之外的 unicode 字符添加转义序列。
因此,您唯一的办法是手动重新编码为 UTF-16 代理项对并使用两次 UTF-16 转义。
您的示例代码点 U+10428
是 "\uD801\uDC28"
。
我使用这个网站进行重新编码:https://rishida.net/tools/conversion/
3.10.5 String Literals
A string literal consists of zero or more characters enclosed in double quotes. Characters may be represented by escape sequences (§3.10.6) - one escape sequence for characters in the range U+0000 to U+FFFF, two escape sequences for the UTF-16 surrogate code units of characters in the range U+010000 to U+10FFFF.
关于java - 如何在 Java 中编写 3 个字节的 unicode 文字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24633273/