3 回答
TA贡献1775条经验 获得超11个赞
JSP在地址里直接传汉字是有这个乱码问题。可以采用
public String tostring(String s){
String str=s;
try{
byte bytes[]=str.getBytes("ISO-8859-1");
str=new String(bytes,"GBK");
return str;
}catch(Exception e){
return str;
}
}
public String ex_chinese(String str){
if(str==null){
str ="" ;
}
else{
try {
str = new String(str.getBytes("iso-8859-1"),"gb2312") ;
}
catch (Exception ex) {
}
}
return str ;
}
来转换!
TA贡献1891条经验 获得超3个赞
应该是编码格式的问题吧
//ISO编码转为GBK编码
public static String ISOtoGBK(String s) {
String str = "";
try {
if (s == null || s == "" || s.equals("")) {
str = s;
} else {
str = new String(s.getBytes("ISO8859-1"),"GBK");
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return str;
}
- 3 回答
- 0 关注
- 1377 浏览
添加回答
举报