查看字编码(Windows上)

以下是在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

猜你喜欢

转载自blog.csdn.net/jinold/article/details/4387834
今日推荐