乱码处理初期小技巧

乱码处理初期小技巧
1。先打印出来:
System.out.println(testString);
2。这一段出现了乱码,那么不妨用穷举法猜测一下它的实际编码格式。
System.out.println(new String(testString.getBytes("ISO-8859-1"),"gb2312"));
System.out.println(new String(testString.getBytes("UTF8"),"gb2312"));
System.out.println(new String(testString.getBytes("GB2312"),"gb2312"));
System.out.println(new String(testString.getBytes("GBK"),"gb2312"));
System.out.println(new String(testString.getBytes("BIG5"),"gb2312"));
3。进行相应的处理。

你可能感兴趣的:(乱码处理初期小技巧)