62,616
社区成员
发帖
与我相关
我的任务
分享
String str = "中";
byte[] bt = str.getBytes("GB2312");
for (byte value : bt) {
// print byte value.
System.out.println(value);
}
System.out.println(new String(bt, "GB2312"));
char src = 0x4e2d; //中文字'中'
System.out.println("原始字符:" + src);
byte high = (byte) (src >> 8);
byte low = (byte) (src);
System.out.println("高字节:" + Integer.toHexString(high));
System.out.println("低字节:" + Integer.toHexString(low));
// System.out.println(new String(new byte[]{(byte)high, (byte)low}, "GB2312"));
System.out.println(new String(new byte[]{high, low}, "UTF16"));