java中文转bytes
引出问题
String s = "哈哈";
System.out.println(Arrays.toString(s.getBytes()));
//[-27, -109, -120, -27, -109, -120]
问题:为什么 “哈” 对应 [-27,-109,-120]
先通过在线工具得出 “哈” 的utf-8编码
通过转换
所以此时中文是以utf-8的编码存储在计算机中对应三个字节
java中文转bytes
引出问题
String s = "哈哈";
System.out.println(Arrays.toString(s.getBytes()));
//[-27, -109, -120, -27, -109, -120]
问题:为什么 “哈” 对应 [-27,-109,-120]
先通过在线工具得出 “哈” 的utf-8编码
通过转换
所以此时中文是以utf-8的编码存储在计算机中对应三个字节