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"));

解决方案 »

  1.   

    开发环境统一编码UTF-8,再无编码转换问题。
      

  2.   

    希望能帮到你LZ.........public static final String GBK = "GBK";//定义编码方式
      //字符串转码
        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;
      }
      

  3.   

    那只能转GBK转其他呀,把GBK改成参数倒是可以,但也会很烦的,
    所以无论你搞什么都是统一的编号再好,或者支持主流的几种编码就可以了,