溫馨提示×

java中unicode轉string的方法是什么

小億
160
2024-06-05 10:09:19
欄目: 編程語言

在Java中,可以使用String類的String(byte[] bytes, Charset charset)構造函數將Unicode編碼的字節數組轉換為字符串。示例如下:

byte[] unicodeBytes = {0x00, 0x48, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F};
String unicodeString = new String(unicodeBytes, StandardCharsets.UTF_16);
System.out.println(unicodeString); // 輸出:Hello

另外,String類還提供了String(byte[] bytes, int offset, int length, Charset charset)構造函數,可以指定字節數組的偏移量和長度。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女