String str1="a"; String str2="b"; String str3="c"; String str4="abc"; System.out.println(str1.getBytes("UTF-16").length);//4 System.out.println(str2.getBytes("UTF-16").length);//4 System.out.println(str3.getBytes("UTF-16").length);//4 System.out.println(str4.getBytes("UTF-16").length);//8 System.out.println(str1.getBytes("UTF-8").length);//1 System.out.println(str2.getBytes("UTF-8").length);//1 System.out.println(str3.getBytes("UTF-8").length);//1 System.out.println(str4.getBytes("UTF-8").length);//3 System.out.println(str1.getBytes("UTF-32").length);//4 System.out.println(str2.getBytes("UTF-32").length);//4 System.out.println(str3.getBytes("UTF-32").length);//4 System.out.println(str4.getBytes("UTF-32").length);//12Unicde编码中不明白的,像UTF-8/UTF-32中str4编码后字节数都是str1+str2+str3,但UTF-16则不然,UTF-16到底是如何编码的呢?求赐教。
添加回答
举报
0/150
提交
取消