字符编码笔记:ASCII,Unicode和UTF-8
非关语言: 乱码 1/2
点击打开链接byte[] bs = new byte[]{(byte)0xe4,(byte)0xb8,(byte)0xa5};
byte[] bg = new byte[]{(byte)0xd1,(byte)0xcf};
byte[] bc = new byte[]{(byte)0x32,(byte)0x61};
printByte("严".getBytes());
printByte("严".getBytes("utf-8"));
printByte("严".getBytes("iso-8859-1"));
System.out.println(new String(bs,"utf-8"));
System.out.println(new String(bg,"gb2312"));
System.out.println(new String(bc,"utf-8"));
static void printByte(byte[] bs) {
int n;
for (int i=0; i<bs.length; i++) {
n = bs[i] & 0xff;
System.out.printf("0x%X ",n);
}
System.out.println();
}
输出