- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在开发应该支持英语、俄语和韩语的 Java 应用程序。
所以我已经为每种语言准备了 unicode 格式的属性文件。然后我使用 bundle 中的 _ 函数获取一些字符串值,将其设置为
InputStream stream = LocaleManager.class.getClassLoader().getResourceAsStream(path);
ResourceBundle bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8"));
public static String _(String key) {
return bundle.getString(key);
}
对于英语和俄语,它工作完美。对于韩语,JTextArea 可以正确显示韩语字符,但 JLabel 不能。它显示正方形,在 Eclipse 控制台中显示 ??,但是俄罗斯字符可以在 Eclipse 控制台中正确显示。
看来 JLabel 有问题。
最佳答案
@mKorbel 很容易确定问题出在 JLabel 字体上。
在应用程序启动时从 Locale.getDefault() 识别语言或要求用户选择。然后根据选择的语言生成pick .properties文件的路径。
在我放入的韩语文件中(我使用 Eclipse AnyEdit 插件) 游泳=\u0412\u043e\u0434\u043d\u043e\u0435 运行=\u0411\u044b\u0441\u0442\u0440\u043e\u0435
InputStream stream = LocaleManager.class.getClassLoader().getResourceAsStream(path);
ResourceBundle bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8"));
//get internationalized version for "Swimming"
String str = _("Swimming");
//create and configure JLabel
JLabel label = new JLabel();
label.setVisible(true);
label.setBackground(Color.yellow);
label.setOpaque(true);
//this line was the issue
label.setFont(new Font("Verdana", Font.PLAIN, 14));
//setting text which results in squares
label.setText(str);
关于java jlabel setText(str) 当str有韩文字符时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12912283/
在Python中,对于日语、中文和韩语,Python无法打印正确的字符串,例如日语、韩语和中文中的hello是: こんにちは 안녕하세요 你好 并打印这些字符串: In [1]: f = open('
在Python中,对于日文、中文、韩文,Python无法打印出正确的字符串,例如hello在日文、韩文、中文中是: こんにちは 안녕하세요 你好 并打印这些字符串: In [1]: f = open(
我有清理 URL 和文件名的功能,它可以很好地处理像 éáßöäü 这样的字符,因为它用 eassoau 等替换它们。使用 str_replace($a, $b, $值)。但是我怎样才能替换中文、日文
我有清理 URL 和文件名的功能,它可以很好地处理像 éáßöäü 这样的字符,因为它用 eassoau 等替换它们。使用 str_replace($a, $b, $值)。但是我怎样才能替换中文、日文
我有如下文字: 아니다 bukan 싫다 tidak suka 훌륭하다 bagus 我正在尝试删除英文行(英文字母)并将其附加到上行(韩文字母)的末尾,如下所示: 아니다bukan 싫다tidak
问题: 在 GIT 中使用 ls 将文件名中的所有 unicode 显示为“?” (即 ???.mp3)。 使用 git add -A 时返回以下错误:“fatal: unable to stat '
我正在考虑使用 DejaVu 字体为 CJK 脚本创建 [Ruby-like][1] 字体。 但是我不确定,是否 DejaVu 提供/支持 CJK 字形? 否则,您是否推荐了另一种可重复使用的免费/开
我有一个图像目录,每个图像的名称中都有一个汉字。我正在尝试列出所有图像,在列表上循环,读取并显示每个图像。 图片路径类似于https://github.com/sirius-ai/LPRNet_Pyt
这个问题在这里已经有了答案: What is proper way to test if the input is Korean or Chinese using JavaScript? (2 个答
我想在 UITextView 中设置斜体字体样式,但斜体字体在 iOS 7 上不适用于中文/日文/韩文。有人能帮忙吗? 最佳答案 因为iOS上没有斜体中文字体,需要使用affine transform
我希望能够识别中文、日文和韩文的书面字符,既可以作为一般语言,也可以作为分割语言。这些是原因: 将 CJK 识别为一个通用组:我正在制作一个垂直脚本蒙古语 TextView。为此,我需要将文本行旋转
我正在使用 ROR 和 Prawn 生成 PDF。 PDF 有英文(表格标签)和日文或其他 FE 语言(用户输入的数据)。 我在建议 ipamp.ttf 的地方找到了与此相关的问题。我安装了该字体,它
我正在使用 MS SQL 2008 Express 连接到我拥有数据库的共享 MS SQL 2008 服务器。数据库的默认排序规则当前为 SQL_Latin1_General_CP1_CI_AS。最终
我是一名优秀的程序员,十分优秀!