字符编码问题
public class characterEncoding {
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
byte [] a="我爱中国".getBytes();
byte [] b="我爱中国".getBytes("iso-8859-1");
String str_gbk=new String(b, "gbk");
//str_iso为什么是乱码?
String str_iso=new String(b, "iso-8859-1");
String str_default=new String(a);
System.out.println("str_gbk="+str_gbk);
System.out.println("str_iso="+str_iso);
System.out.println("str_default="+str_default);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}