问题遇到的现象和发生背景
new String(s.getBytes("ISO-8859-1"), "UTF-8")转换后还是乱码怎么回事
问题相关代码,请勿粘贴截图
package javaweb1;
public class ChineseToString {
public ChineseToString() {
// TODO Auto-generated constructor stub
}
/**
* 构造方法
*/
public String toString(String s) {
String text = "";
// 判断要转码的字符串是否有效
if (!s.equals("") && !s.equals("null")) {
try {
// 将字符串进行编码处理
text = new String(s.getBytes("ISO-8859-1"), "UTF-8");
} catch (Exception e) {
e.printStackTrace();
}
}
return text;
}
/**
* 转码处理字符串
*
* @param s 要转码的字符串
*
* @return 转码后的字符串
*/
public static void main(String[] args) {
System.out.println(new ChineseToString().toString("达到"));
}
}
运行结果及报错内容

我想要达到的结果
正常显示中文