在 Java/Swing 中显示特殊的 unicode 字符 [英] Displaying special unicode characters in Java/Swing

查看:53
本文介绍了在 Java/Swing 中显示特殊的 unicode 字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想画这样的特殊字符( http://www.fileformat.info/info/unicode/char/2605/index.htm )在 JLabel 中.它在 Mac OS X 上运行良好.

I wanted to draw special characters like this one ( http://www.fileformat.info/info/unicode/char/2605/index.htm ) in JLabel. It's working great on Mac OS X.

为了避免编码问题,我这样定义:

To avoid encoding problem, I've defined this like that :

public static final char STAR = '\u2605';

但在 Windows 7 上,我有一个代表未知字符的方块.我用谷歌搜索过,看起来我们需要手动编辑 JRE 使用的字体配置文件.

But on Windows 7, I've got a square representing an unknown character. I've googled and it looks like we need to hand-edit the font configuration files that the JRE uses.

我希望我的应用程序是可移植的并且不需要用户的这种干预.

I would like my application to be portable and not requiring this kind of intervention from the user.

任何想法都值得赞赏.非常感谢!

Any idea is appreciated. Many thanks !

推荐答案

问题很可能是特定字符不是 windows 平台字体的一部分.许多更高的 unicode 字符就是这种情况.你需要找到一个在所有平台上都存在的.

The problem is most likely that the specific character is not part of the font on the windows platform. This is the case for many higher unicode chars. You need to find one that exists on all platforms.

甚至在不同平台上称为相同的字体可能对字符的支持完全不同.您可以尝试切换字体,看看是否可以找到跨平台始终带有星号的字体.

It's even the case that a typeface called the same on different platforms may have entirely different support of chars. You could try switching the typeface and see if you can find one that has the star consistently across platforms.

您对 unicode 字符的编码是完全可移植的.

Your encoding of the unicode char is completely portable.

这篇关于在 Java/Swing 中显示特殊的 unicode 字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆