例如:
public static String convertCode(String str)
{
if (str == null)
str ="";
try{
str = new String(str.getBytes("ISO-8859-1"),"GB2312");
}
catch(Exception ex){
return "";
}
return str;
}

解决方案 »

  1.   

    public static String UnicodeToChinese(String s){
      try{
         if(s==null||s.equals("")) return "";
         String newstring=null;
         newstring=new String(s.getBytes("ISO8859_1"),"gb2312");
         return newstring;
        }
      catch(UnsupportedEncodingException e)
      {
      return s;
      }
      }
      

  2.   

    入库前把要入库的值用编码转换函数转换一下.public String changstr(String temp)
    {
       try
       {
             String str = temp;
    byte[] str_1 = str.getBytes("IOS8859-1");
    String str_2 = new String(str_1);
    return str_2;
       }
       catch(Exception e)
       {
    return temp;
       }
    }