public static String encodeStr(Stringstr) {
if(str==null||"".equals(str)){
return "";
}
try {
//判断是否"ISO-8859-1"编码
if(str.equals(new String(str.getBytes("ISO-8859-1"), "ISO-8859-1"))){
return new String(str.getBytes("ISO-8859-1"), "UTF-8");
}
return str;
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return null;
}
}
解决中文乱码
最新推荐文章于 2018-05-18 16:26:16 发布