public static void DoOut(String str){ try { System.out.println("0"+str); System.out.println("1:{gbk > utf-8}"+new String(str.getBytes("gbk"),"utf-8")); System.out.println("2: {gb2312 > utf-8}"+new String(str.getBytes("gb2312"),"utf-8")); System.out.println("3: {utf-8 > gb2312}"+new String(str.getBytes("utf-8"),"gb2312")); System.out.println("4: {utf-8 > gbk}"+new String(str.getBytes("utf-8"),"gbk")); System.out.println("5: {gb2312 > gbk}"+new String(str.getBytes("gb2312"),"gbk")); System.out.println("6: {gbk > gb2312}"+new String(str.getBytes("gbk"),"gb2312")); System.out.println("7: {utf-8 > utf-8}"+new String(str.getBytes("utf-8"),"utf-8")); System.out.println("8: {ISO-8859-1 > gb2312}"+new String(str.getBytes("ISO-8859-1"),"gb2312")); System.out.println("9: {utf-8 > ISO-8859-1}"+new String(str.getBytes("utf-8"),"ISO-8859-1")); System.out.println("10: {ISO-8859-1 > utf-8}"+new String(str.getBytes("ISO-8859-1"),"utf-8")); System.out.println("11: {ISO-8859-1 > gbk}"+new String(str.getBytes("ISO-8859-1"),"gbk")); System.out.println("12: {gb2312 > ISO-8859-1}"+new String(str.getBytes("gb2312"),"ISO-8859-1")); System.out.println("12: {gbk > ISO-8859-1}"+new String(str.getBytes("gbk"),"ISO-8859-1")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } }
java 编码测试
最新推荐文章于 2024-06-09 18:30:55 发布