我是用Tomcat5.0.28
服务器运行在RH AS4上
jsp调用javabean写硬盘文件(写.csv格式的文件,因为xls只能有65535条记录,不够用)
在Windows下调试出来的csv文件没有编码问题,在RH下文件变为UTF-8
写文件的时候用new String(str.getBytes("utf-8"),gb2312)处理过每个字符,但是还是乱码...
请教

解决方案 »

  1.   

    试试new String(str.getBytes("iso-8859-1"),gb2312)tomcat默认编码是iso88591rh是utf-8编码?
      

  2.   

    忘说了
    String ss = new String(s.getBytes("ISO-8859-1"),"gb2312");这样也没用
      

  3.   

    public static String toChinese(String s)throws UnsupportedEncodingException 
    {
    if (s == null || s.trim().length() == 0) {
    return null;
    } else {
    //String ss = new String(s.getBytes("ISO-8859-1"),"gb2312");
    String ss = new String(s.getBytes("iso-8859-1"),"gb2312");
    return ss;
    }这个是我的编码转换类