试试先转换成Unicode,再转成你需要的字符编码。getByte().

解决方案 »

  1.   

    public static String getWriteStr(String str) {
            try {
                String temp_p = str;
                byte[] temp_t = temp_p.getBytes("GBK");
                String unicode = new String(temp_t,"ISO8859-1");
                return unicode;
            }
            catch(Exception e) {
                return "null";
            }
        }
      

  2.   

    public static String toGBK(String strValue){
            //将strValue编码转换为GBK,防止乱码。
            try{
                byte buf[]=strValue.getBytes("ISO8859-1");
                String string=new String(buf,"GBK");
                String str=string;
                return str;
            }catch(Exception ex){
                String eStr=null;
                return eStr;
            }
        }
        
    public static String toISO8859(String strValue){
    //将strValue编码转换为GBK,防止乱码。
    try{
    byte buf[]=strValue.getBytes("GBK");
    String string=new String(buf,"ISO8859-1");
    String str=string;
    return str;
    }catch(Exception ex){
    String eStr=null;
    return eStr;
    }
    }
      

  3.   


    String tmp = new String(strUnicode.getBytes("UTF-16BE"), "GB2312");其中,tmp就是GB2312的字符串。strUnicode是转换前的字符串。