打印特定范围内的所有Unicode字符

我找不到合适的API。 我试过这个;

public static void main(String[] args) { for (int i = 2309; i < 3000; i++) { String hex = Integer.toHexString(i); System.out.println(hex + " = " + (char) i); } } 

此代码仅在Eclipse IDE中以这样的方式打印。

 905 = ? 906 = ? 907 = ? ... 

如何使用这些十进制和hex值来获取Unicode字符?

它打印得像那样,因为所有控制台都使用单声道间隔字体。 在框架中的JLabel上尝试它,它应该显示正常。

编辑:

尝试创建unicode打印流

 PrintStream out = new PrintStream(System.out, true, "UTF-8"); 

然后打印到它。

这是CMD窗口中的输出。

在此处输入图像描述

我忘了通过更改它来保存为UTF-8格式

文件>属性>选择文本文件编码

这将从Eclipse控制台正确打印正确的字符。 默认为cp1252,仅打印? 对于那些不明白的人物。