String name="中国";
System.out.println("UTF-8==>ISO-8859-1\t"+new String(name.getBytes("utf-8"),"iso-8859-1"));
System.out.println("UTF-8==>GBK\t"+new String(name.getBytes("utf-8"),"gbk"));
System.out.println("UTF-8==>UTF-8\t"+new String(name.getBytes("utf-8"),"utf-8"));
System.out.println("ISO-8859-1==>ISO-8859-1\t"+new String(name.getBytes("iso-8859-1"),"iso-8859-1"));
System.out.println("ISO-8859-1==>GBK\t"+new String(name.getBytes("iso-8859-1"),"gbk"));
System.out.println("ISO-8859-1==>UTF-8\t"+new String(name.getBytes("iso-8859-1"),"utf-8"));
System.out.println("GBK==>ISO-8859-1\t"+new String(name.getBytes("gbk"),"iso-8859-1"));
System.out.println("GBK==>GBK\t"+new String(name.getBytes("gbk"),"gbk"));
System.out.println("GBK==>UTF-8\t"+new String(name.getBytes("gbk"),"utf-8"));
输出:
UTF-8==>ISO-8859-1 ä¸å›½
UTF-8==>GBK 涓浗
UTF-8==>UTF-8 中国
ISO-8859-1==>ISO-8859-1 ??
ISO-8859-1==>GBK ??
ISO-8859-1==>UTF-8 ??
GBK==>ISO-8859-1 Öйú
GBK==>GBK 中国
GBK==>UTF-8 �й�