尝试打出所有的中文字符,中文字符的16进制范围是[u4e00-u9fa5]。
public static String toStringHex(String s) throws Exception {
byte[] baKeyword = new byte[s.length()/2];
for(int i = 0;i < baKeyword.length; i++){
baKeyword[i] = (byte)(0xff & Integer.parseInt(s.substring(i*2,i*2+2),16));
}
s = new String(baKeyword,"utf-16");
return s;
}
public static void main(String[] args) throws Exception {
System.out.println(Integer.valueOf("4e00",16));//19968
System.out.println(Integer.valueOf("9fa5",16));//40869
for (int i = 19968;i <= 40869;){
for(int j = 0;j < 60 && i <= 40869; j++,i++){
System.out.print(toStringHex(Integer.toHexString(i)));
}
System.out.println();
}
}