黑莓手机 - 统一code文本显示器 [英] BlackBerry - Unicode text display
问题描述
我想显示一些阿拉伯文文本中的LabelField J2ME应用程序的BlackBerry设备上。
presume的阿拉伯字体安装在设备上。
I would like to display some Arabic text into LabelField in j2me app on BlackBerry device. Presume that Arabic font is installed on device.
在本地化资源,如果使用阿拉伯语语言环境中,所有的文本保存在统一code序列。但是,事件,如果我用这种形式明确,还设置阿拉伯语的语言环境,它不工作:
In localization resources, if Arabic locale is used, all text is saved in Unicode sequences. But event if I use such format explicitly, also setting Arabic locale, it's not working:
Locale.setDefault(Locale.get(Locale.LOCALE_ar, null));
add(new LabelField("\u0627\u0644\u0639\u0631\u0628\u064A\u0629"));
请咨询:
- 在什么样的格式或code页面我要救阿拉伯文字?
- 如何使用安装阿拉伯字体显示在标签阿拉伯文字?
感谢您!
推荐答案
解决方案是通过统一code序列作为一个字符数组:
Solution is to pass Unicode sequence as a char array:
char[] text = new char[] {'\u0627', '\u0644', '\u0639',
'\u0631', '\u0628', '\u064A', '\u0629'};
add(new LabelField(text));
所以要显示在保持统一的字符串code序列,我们需要把这个字符串解析成字符:
So to display Unicode sequence kept in String, we need to parse this String into chars:
private char[] getUnicodeChars(String string) {
char[] result = new char[] {};
String[] charCodes = split(string, "\\");
result = new char[charCodes.length];
for (int i = 0; i < charCodes.length; i++) {
result[i] = (char) Integer.parseInt(charCodes[i].substring(1), 16);
}
return result;
}
和在code的地方:
String txt = "\u0627\u0644\u0639\u0631\u0628\u064A\u0629";
add(new LabelField(getUnicodeChars(txt)));
和没有必要切换区域设置。当然,阿拉伯字体应安装。
And there is no need to switch Locale. Of course Arabic font should be installed.
这篇关于黑莓手机 - 统一code文本显示器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!