java 3个字节,如何在Java中编写3个字节的unicode文字?

I tried with '\u10428' and it doesn't compile.

解决方案

Because Java went full-out unicode when people thought 64K are enough for everyone (Where did one hear such before?), they started out with UCS-2 and later upgraded to UTF-16.

But they never bothered to add an escape sequence for unicode characters outside the BMP.

Thus, your only recourse is manually recoding to a UTF-16 surrogate-pair and using two UTF-16 escapes.

Your example codepoint U+10428 is "\uD801\uDC28".

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值