×
Namespaces

Variants
Actions

最新中文版本 Tips on Chinese Chars

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

文章
kcomex 在 14 Mar 2007 创建
最后由 hamishwillee 在 15 Aug 2013 编辑

Contents

最新中文版本

背景

在S60开发中,我们中国的开发者和初学者现在已经可以使用诺基亚论坛的讨论版找到自己需要的问题的答案,或者仅仅借助于google就可以解决问题。不过仍然会有一些和中文有关的问题,因为国外开发者它们并不会遇到,所以有些问题并不会被总结出来。这里就给大家介绍几个小窍门,希望能给大家的开发带来帮助。

窍门而已

第一条

如果你想在CCoeControl::Draw的函数中将中文“画”在屏幕上的话,只需要用下面的字体变量即可使用中文了:

#include <aknutils.h>
 
const CFont* fontBig = ApacPlain16(); //大字体
 
const CFont* fontSmall = ApacPlain12(); //小字体

注意!使用限制有: 如上代码仅供S60平台使用,并不能被使用在UIQ等其他Symbian平台上。理想情况下,所有的S60手机都可以使用上述代码,但是,对于双倍高分辨率的手机(如N80,N90等416x352分辨率的手机),因为这些手机使用的是矢量TTF字体,所以如上所述的点阵将有可能不可用。因为真机情况我在写这篇wiki时并没有验证,所以这条限制还有待证实。

第二条

如果你只是想临时显示几个汉字,仅仅作为临时使用,并不想使用麻烦的官方的 .LOC--.RSS--TBuf 方式来显示汉字的话,下面的这个Macro即可被用来显示“一”这个字。

_L("\x4E00");

如果你还想显示其他文字,只需要在_L Macro中使用\xHHHH四位Unicode16进制数值即可。你可以使用UltraEdit32这个工具的16进制视图来查找汉字的Unicode值。比如要显示"诺基亚"三个字你只需新建文本文件,输入“诺基亚”三个字,然后按Unicode编码保存,使用UltraEdit32打开该文件,按下Ctrl+H切换到16进制模式,你就会看到这样的数值, "FA 8B FA 57 9A 4E",按照小尾数(LittleEndian)模式组合数值,得到的

_L("\x8BFA\x58FA\x4E9A");

就是"诺基亚"三个汉字。

需要牢记,这个方法仅仅作为“临时”使用;如果有一长段文字,而且很有可能会经常变化的话,你就千万不能使用这个方法。零食可千万不能当饭吃!

来日方长

国内的开发者需要合作,需要互助互惠来共同进步。我希望以这篇wiki开始我和我们的贡献之路,总结我们的经验,让我们的未来更美好。

本文将会继续扩充,不断增加窍门和技巧。凡是有关中文和汉字方面的问题,欢迎您关注本文。


原始英文版本

Background

In S60 development, Chinese developers and beginners could find solutions to their problems very quickly by search the discussion boards or just by google. But problems we can find few solution are the ones related to Chinese characters.

Just tips

1, If you want to obtain Chinese fonts, just do this

#include <aknutils.h>
 
const CFont* iFont = ApacPlain16(); // big font
 
const CFont* iFont = ApacPlain12(); // small font

Limitation: This code could only be used in S60 Platform, not UIQ or other Symbian platform. Ideally this code could be used on every S60 phone, but I should make a warning that double solution (416x352) phones might in trouble with this, cause those phones come with scalable fonts, not the classical big and small two raster dot-matrix fonts.


2, If you really want to display some temporary characters in Chinese, and don't want to do the .LOC--.RSS--TBuf fussy official chain tasks, then you might need this:

_L("\x4E00");

this is the first character 'one'/(1) in Chinese, and other characters could be looked up in UltraEdit32 editor's hex view. But please ensure you are using Unicode mode while open the file. for example, if you want to display the characters "诺基亚", you could type these chars in UltraEdit32, and press Ctrl+H to hex view, then you will see the char values, "FA 8B FA 57 9A 4E" and you could make chars in Symbian fashion as follows:

_L("\x8BFA\x58FA\x4E9A");

Then thats "诺基亚".

But this is only a way to display some short chars TEMPORARILY , please do not use this for a whole passage of texts, those might change!!!


Whats next

Chinese developers needs unite, and I want to make more contribute and invite more friends to this contribute, this article will extend in future and focus any tips about Chinese characters display.

This page was last modified on 15 August 2013, at 14:35.
69 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×