import java.io.UnsupportedEncodingException;
public class main {
public static void main(String[] args) throws UnsupportedEncodingException{
byte [] b= new byte[]{(byte) 0xcc,(byte) 0xe1,(byte) 0xbd,(byte) 0xbb};
String s = new String(b,"ISO8859-1");
System.out.println(s);
print(s.getBytes("ISO8859-1"));
print(s.getBytes("GBK"));
print(s.getBytes("UTF-16"));
System.out.println(new String(s.getBytes("ISO8859-1"),"gbk"));
String ss = "中文";
print(ss.getBytes("UTF-16"));
print(ss.getBytes("ISO8859-1"));
}
static void print(byte [] b){
for(byte _b : b){
String s = Integer.toHexString(_b&0xff);
if(s.length()==1){
s = "0"+s;
}
System.out.print(s + " ");
}
System.out.println();
}
}
Bytes("ISO8859-1"),"GBK")的实质
最新推荐文章于 2024-09-21 22:18:00 发布