new String(str.getBytes("ISO-8859-1"),"UTF-8");
new String(str.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"));
new String(str.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"));
//字符串转码
public static String toUTF_8(String str) throws UnsupportedEncodingException{
return XMLReadimpl.changeCharset(str, GBK);
}
public static String changeCharset(String str, String newCharset)throws UnsupportedEncodingException {
if (str != null) {
//用默认字符编码解码字符串。
byte[] bs = str.getBytes();
//用新的字符编码生成字符串
return new String(bs, newCharset);
}
return null;
}
所以无论你搞什么都是统一的编号再好,或者支持主流的几种编码就可以了,