飞网论坛

标题: 160、我们在web应用开发过程中经常遇到输出某种编码的字符? [打印本页]

作者: johnny    时间: 2016-9-7 23:05
标题: 160、我们在web应用开发过程中经常遇到输出某种编码的字符?

160、我们在web应用开发过程中经常遇到输出某种编码的字符,如iso8859-1等,如何输出一个某种编码的字符串?

Public String translate (String str) {

String tempStr = "";

try {

tempStr = new String(str.getBytes("ISO-8859-1"), "GBK");

tempStr = tempStr.trim();

}

catch (Exception e) {

System.err.println(e.getMessage());

}

return tempStr;

}







欢迎光临 飞网论坛 (https://bbs.cfei.net/) Powered by Discuz! X3.2