public static String toGBK(String str){
if(str==null) str="";
else
try {
str=new String(str.getBytes("ISO-8859-1"),"GBK");
} catch (UnsupportedEncodingException e) {
System.out.println("转换字符串异常!"+e.getMessage());
e.printStackTrace();
}
return str;
}
public static String toUTF8(String str){
if(str==null) str="";
else
try {
str=new String(str.getBytes("ISO-8859-1"),"UTF8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return str;
}
|