JAVA的字符编码问题,错误解码,再编码,再正确解码,出来是乱码
示例代码如下: /*
- To change this template, choose Tools | Templates
- and open the template in the editor. */ package javacharsettest;
import java.io.UnsupportedEncodingException;
/** *
-
@author jiayp */ public class Main {
/**
-
@param args the command line arguments */ public static void main(String args) { // TODO code application logic here try { String str = "a你好b"; str = new String(str.getBytes("GBK"), "UTF-8"); str = new String(str.getBytes("UTF-8"), "GBK");
System.out.print(str);}catch(UnsupportedEncodingException e){};
} }
-
请问有办法把错误解码的字符串给还原回去吗?