标签: java encoding utf-16
字符“ A”应该在UTF8中具有0x41的Unicode,在UTF16中具有0x0041的Unicode,当我尝试获取A的字节时,我得到2个负数,为什么我没有得到0 0 0 65?
String x = "A"; byte[] bytes = x.getBytes("UTF16"); System.out.println(Arrays.toString(bytes));
[-2,-1,0,65]