本文介绍了打印特定范围内的所有Unicode字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我找不到正确的API。我试过这个;
I can't find the right API for this. I tried this;
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中打印。 / p>
This code only prints like this in Eclipse IDE.
905 = ?
906 = ?
907 = ?
...
如何让我们使用这些十进制和十六进制值来获取Unicode字符?
How can I make us of these decimal and hex values to get the Unicode characters?
推荐答案
它打印成这样,因为所有控制台都使用单声道间隔字体。尝试在一个JLabel框架,它应该显示正常。
It prints like that because all consoles use a mono spaced font. Try that on a JLabel in a frame and it should display fine.
编辑:
尝试创建一个unicode printstream
Try creating a unicode printstream
PrintStream out = new PrintStream(System.out, true, "UTF-8");
然后打印。
这是CMD窗口中的输出。
Here's the output in CMD window.
这篇关于打印特定范围内的所有Unicode字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!