How to display Chinese characters under Symbian Series60

xiaoxiao2021-03-05  21

How to display Chinese characters under Symbian Series60

2005-4-24

Tang Liang

1. The simulator in the SDK development package displays Chinese characters. Only Chinese version of the simulator can display Chinese characters (except for the own "). If it is an English version of the simulator, directly display the Chinese character encoding of GB, except for the displayed Chinese characters, the program will have an exception error. English version of the simulator, such as SDK 1.2, the only way to show Chinese characters is to bring a letter library or drawing. Although such a method is more complicated, it is easy to transplant. And don't worry about different models of font size. Chinese version of the simulator, such as SDK

2.1C

The simulator is a Chinese character encoding that directly displays GB. However, it is still not possible on the actual machine. Because Symbian is unicode encoding for text. Must be converted to display.

2. Display Chinese characters on real phones. Although installing language can be selected in the PKG file in Makesis, such as English en, Chinese, but this installation option does not have any use at all. Symbian uses Unicode encoding, which only look at your Unicode encoding, don't look at other. So to solve the Chinese character problem, we must convert our Chinese character encoding. The conversion method is divided into static conversion and dynamic conversion: static conversion: define resource tbuf64 r_example_view_title {buf = "Happy New Year" in the RSS resource file;} then convert it to UTF8 encoding, add character_set in this RSS file head UTF8, otherwise it will not be able to compile, and then call in the program.

In your program, you have to include the RSG header file generated by the RSS file, which contains #define r_example_view_title 0x24da2006

Then in the program, use the following functions to create a resource HBUFC * CCoEenv :: AllocReadResourcec (Tint AresourceId) Const this approach is not very good, because all the text resources are put in the RSS resource file, if our procedure has yourself The resource file is not good to store the text. After Windows98, Windows provides an API function on Unicode's conversion. We can write a program to convert UTF8 conversions for text. Below is the two Windows ApimultibytetowideCharWideChartomultibyte below is a conversion function I write. Typedef struct _UTF8

{

U16 LEN;

Char string [max_char]; // does not include strings length

} UTF8; //

// DESC: Convert a regular string into a UTF8 encoded string

UTF8 * UTF8_CONVERT (const char * string)

{

CHAR UTF8 [10 * max_char];

Wchar WSTR [10 * max_char];

Int WSZ;

INT utf8sz;

UTF8 * PUTF8;

WSZ = MULTIBYTOWIDECHAR (CP_ACP, 0, (const char *) String, (int) Strlen (String) 1, WSTR, SIZEOF (WSTR) / SizeOf (WSTR [0]));

UTF8SZ = Widechartomultibyte (CP_UTF8, 0, WSTR, -1, UTF8, SIZEOF (UTF8), NULL, NULL;

PUTF8 = (UTF8 *) Malloc (SIZEOF (UTF8));

STRCPY (PUTF8-> String, UTF8);

PUTF8-> LEN = (U16) (UTF8SZ-1);

Return Putf8;

} Dynamic conversion: Symbian has provided API for Unicode conversion since 5.1. Here is a function I have sorted out, and you can use it directly to paste the past. Note that this program needs to increase header file charconv.h and library file charconv.libhufc16 * Cappview :: ConvertTounicode (Ttext * text)

{

// ccnvcharacterSetConverter API to convert

CcnvcharacterSetConverter * Converter = ccnvcharacTerSetConverter :: newlc ();

IF (Converter-> PreparetoconvertToorfroml (KcharacterSetIdentifierGBK, Icoeenv-> fssession ())! = ccnvcharactersetConverter :: Eavailable)

User :: Leave (KerrNotSupported);

Ttext8 * Str = (TTEXT8 *) Text;

Tint State = ccnvcharacTerSetConverter :: kStatedEfault;

TPTRC8 SOURCE (STR);

HBUFC16 * Iinfotext = HBUFC16 :: newl (Source.Length () * 2);

TPTR16 PTR = Iinfotext-> DES ();

IF (ccnvcharacterSetConverter :: ErrorillForMedInput == Converter-> ConvertTounicode (Ptr, Source, State))

User :: Leave (Kerrargument); // Leave if Error in Conversion.

Cleanupstack :: popanddestroy (); // clean for controller

// delete converter;

Return Iinfotext;

}

转载请注明原文地址:https://www.9cbs.com/read-32268.html

New Post(0)