3 回答

TA貢獻1775條經(jīng)驗 獲得超11個贊
JSP在地址里直接傳漢字是有這個亂碼問題??梢圆捎?br/>
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 ;
}
來轉(zhuǎn)換!

TA貢獻1891條經(jīng)驗 獲得超3個贊
應(yīng)該是編碼格式的問題吧
//ISO編碼轉(zhuǎn)為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 關(guān)注
- 1419 瀏覽
添加回答
舉報