将GB2312编码的字符串转换成ISO-8859-1编码的字符串,测试有问题,请大家帮忙,谢谢了!
//将GB2312编码的字符串转换成ISO-8859-1编码的字符串
import java.io.IOException;
import java.io.UnsupportedEncodingException;
public class C {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
String s1 = "人民币";
System.out.println(s1); //这里输出的是 人民币
String s2 = new String(s1.getBytes("GB2312"),"ISO-8859-1");
System.out.println(s2); //这里输出的是 ????±?
}
}
运行结果为:
人民币
????±?
为什么S2不是人民币呢?