查看字编码(Windows上)

来源:互联网 发布:打的软件 编辑:程序博客网 时间:2024/06/05 23:53

以下是在Windows上的运行结果

 

String str1 = "中";
String str3 = "B";
int is1 = str1.getBytes()[0];
int is2 = str1.getBytes()[1];
int is3 = str3.getBytes()[0];
System.out.println(Integer.toHexString(is1));
System.out.println(Integer.toHexString(is2));
System.out.println(Integer.toHexString(is3));

 

打印结果

 

ffffff92
ffffff86
42

=========================================

 

 

byte s1 = (byte)0x92;
byte s2 = (byte)0x86;
byte s3 = (byte)0x42;
byte ss[]={s1,s2,s3};
System.out.print(new String(ss));

 

打印结果

 

中B

原创粉丝点击