#include “xxx.loc”
RESOURCE CAPTION_DATA
{
caption = qtn_app_caption_string;
shortcaption = qtn_app_short_caption_string;
}
CHARACTER_SET UTF8 //必须加这行
#define qtn_app_caption_string “程序中文名”
#define qtn_app_short_caption_string “显示名”
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);
#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);
}