自己在开发时遇到的一些问题:
1. 将Symbian应用程序改为中文名称
• 修改资源文件xxx_caption.rss:
Code:
#include “xxx.loc”
RESOURCE CAPTION_DATA
{
caption = qtn_app_caption_string;
shortcaption = qtn_app_short_caption_string;
}
• 打开xxx.loc 用记事本或UltraEdit转成UTF-8编码
Code:
CHARACTER_SET UTF8 //必须加这行

#define qtn_app_caption_string “程序中文名”
#define qtn_app_short_caption_string “显示名”
2.在Nokia 7610中文机上显示Shift-JIS编码的日文串
• Symbian平台以Unicode编码,可以表示、显示所有字符,只需将本地编码转为Unicode即可。
• 因为中文机上没有日文字库,所以不能用类CcnvCharacterSetConverter提供的方法
(但可实现GBK -> Unicode)
Code:
CCnvCharacterSetConverter* converter = CCnvCharacterSetConverter::NewLC();
converter->PrepareToConvertToOrFromL(KCharacterSetIdentifierShiftJis, CEikonEnv::Static()->FsSession());
/***************************************************
*上一行会异常退出,因目标平台没有SJIS字库
*但可以实现GBK -> Unicode,只需将KcharacterSetIdentifierShiftJis
*改为KCharacterSetIdentifierGbk
***************************************************/
TInt state = CCnvCharacterSetConverter::KStateDefault;
……
TInt ctu = converter->ConvertToUnicode(bufPtr, srcPtr, state);
• 在网上找了一个实现SJIS到Unicode转换的函数
Code:
#include "cp.h"

#define is_zen(c)
((0x81 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0x9f)
|| (0xe0 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xfc))
#define is_han(c)
((0xa0 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xdf))

s32_t skip_bytes(char c)
{
if(is_zen(c)) {
return 2;
} else if (is_han(c)) {
return 1;
}
return 0;
}

s32_t jis2utf8(char **srcbuf, s32_t *srclen, char **outbuf, s32_t *outlen) {
unsigned char *dst;
unsigned char *src;
unsigned short utf8code;
int sjiscode;
s32_t len;
unsigned char *to2;

if (! (srcbuf && srclen && outbuf && outlen))
return 0;

src = (unsigned char *)*srcbuf;
dst = to2 = (u8_t*)malloc(*outlen);
while (*src && ((dst - to2) < (*outlen - 4))) {
len = skip_bytes(*src);
if ( len == 2 ) {
sjiscode = (int)(*src++ & 0xff);
sjiscode = (int)((sjiscode << 8)|(*src++ & 0xff));
} else {
sjiscode = (int)(*src++ & 0xff);
}

utf8code = cp[sjiscode];// convert sjis code to utf8 (cp[] is conversion table array)

if ( utf8code <= 0x7f ) {
*dst++ = (char)(utf8code & 0xff);
}
else if ( utf8code <= 0x7ff ){
*dst++ = (char)( 0xc0 | ((utf8code >> 6) & 0xff));
*dst++ = (char)( 0x80 | ( utf8code & 0x3f ));
} else {
*dst++ = (char)( 0xe0 | ((utf8code >> 12) & 0x0f));
*dst++ = (char)( 0x80 | ((utf8code >> 6) & 0x3f));
*dst++ = (char)( 0x80 | (utf8code & 0x3f));
}

}
*dst++='';
memcpy(*outbuf,to2,*outlen);
free(to2);
return strlen(*outbuf);
}
1. 将Symbian应用程序改为中文名称
• 修改资源文件xxx_caption.rss:
Code:







• 打开xxx.loc 用记事本或UltraEdit转成UTF-8编码
Code:





2.在Nokia 7610中文机上显示Shift-JIS编码的日文串
• Symbian平台以Unicode编码,可以表示、显示所有字符,只需将本地编码转为Unicode即可。
• 因为中文机上没有日文字库,所以不能用类CcnvCharacterSetConverter提供的方法
(但可实现GBK -> Unicode)
Code:











• 在网上找了一个实现SJIS到Unicode转换的函数
Code:




























































