GBK UTF-8 ISO8859-1编码问题
String str = "中文";System.out.println(new String(new String((str.getBytes("GBK")),"iso8859-1").getBytes("iso8859-1"),"gbk"));
System.out.println(new String(new String((str.getBytes("GBK")),"utf-8").getBytes("utf-8"),"gbk"));
两种转换方式是否结果都是显示“中文”?为什么?
--------------------编程问答-------------------- 经测试,第二种为乱码。
这应该跟各种编码是有关系的,测试后:
System.out.println(new String(new String((str.getBytes("UTF-8")),"GBK").getBytes("GBK"),"UTF-8"));
输出为:中文
补充:Java , Java EE