我想转吗的函数是不是应该为:
 public String getStr(String str)
   {
   try
    {
String temp_p=str;
byte[] temp_t=temp_p.getBytes("ISO8859-1");
String temp=new String(temp_t);
return temp;
}
catch(Exception e)
{}
return "null";
}
用这个试试!
祝你好运!

解决方案 »

  1.   

    楼上的兄弟,你的函数跟楼主的没有什么两样嘛。楼主,你说你要根据T_A表中的一个记录到T_B表中插入一条记录。那么在插入之前你有怎么能够在T_B表中找到这条记录呢?
      

  2.   

    用这个函数试试,祝你成功。<%!
    public String GB2Uni(String GB) {
    //this is a method for servlet loading chinese data from db.
      try {
        if (GB==null){
    return "";
        }
        GB=GB.trim();
        byte[] tmp = GB.getBytes("Cp1252"); 
        //you must change the byte code
        String result = new String(tmp);
        return result;
        } 
        catch(java.io.UnsupportedEncodingException e) {
          System.out.println("CommonFunction.GB2Uni UnsupportedEncodingException"+e);
        return null;
       }
    }
    %>
      

  3.   

    是不是数据库的字符集有问题???
    我曾经把汉字插到access中乱吗,可是 jsp取出来又一切正常。。
      

  4.   

    Oracle数据库。问题已经解决。我在页面之间和页面和bean之间传了变量,转换了两次或以上。我写的函数只能转换一次。谢谢大家!