---------------------------------------------------------------------------
public static String getString(String str) {
String s = null;
try {
s = new String(str.getBytes("GBK"), "UTF-8");
} catch (Exception ex) {
ex.getMessage();
}
return s;
}
-----------------------------------------------------------------------------
怎么存到数据库里的一部分是乱码,一部分不是乱码(如,“我晕”就 不是乱码,“我晕倒”那个“倒”就是乱码,还有“?”号全是两个“?”)
我还试了s = new String(str.getBytes("UTF-8"), "GBK");但是还是不行,请那个高手帮忙给指点一下

解决方案 »

  1.   

    s = new String(str.getBytes("iso-8859-1"), "GBK");
    试试
      

  2.   

    页头没有context我是用的ext框架做的页面
    --------------------------------------------
    s = new String(str.getBytes("iso-8859-1"), "GBK"); 
    s = new String(str.getBytes("UTF-8"), "GBK"); 
    ----------------------
    这样的我都试了,存到数据库的还是乱码,很是郁闷。
      

  3.   

    用过滤器吧,把jsp里面的数据编码按数据库的编码转换。