Mtkuses the ref_list.txt file to uniformly load characters for conversion
Convert the GB code to unicode encoding, because the MTK system only accepts unicode encoding for character function APIs!
Below I want to introduce two methods to directly output the GB code!
Method 1:
We can use the file conversion. the function mmi_chset_text_to_ucs2 (...) in the C file (....) the function is used to convert a string encoded in GB. However, the macro _ mmi_chset_gb2312 _ must be enabled to use this function. Otherwise, garbled characters must be displayed after conversion. Why? Let's take a look at the code snippet:
The conversion. c header contains the following code snippet:
# If defined (_ mmi_chset_big5 _) </P> <p> mmi_chset_enum Limit = mmi_chset_big5; </P> <p> # Elif defined (_ limit __) </P> <p> mmi_chset_enum g_chset_text_encoding = encoding; </P> <p> # else </P> <p> mmi_chset_enum encoding = mmi_chset_utf8; </P> <p> # endif <br/>
It can be seen that if we do not open _ mmi_chset_gb2312 _ macro, g_chset_text_encoding is not the mmi_chset_gb2312 value, but other values, then the function mmi_chset_text_to_ucs2 (....) you cannot convert a string encoded in GB.
Mmi_chset_text_to_ucs2 (...) function snippet:
Kal_int32 mmi_chset_text_to_ucs2 (kal_uint8 * DEST, kal_int32 dest_size, kal_uint8 * SRC) </P> <p >{</P> <p>/* ------------------------------------------------------------ */</P> <p>/* local variables */</P> <p> /* response */</P> <p>/* -------------------------------------------------------------- */</P> <p>/* Code body */</P> <p>/* response /*---------------------------------------------------------------- */</P> <p> return mmi_chset_convert (g_chset_text_encoding, mmi_chset_ucs2, (char *) SRC, (char *) DEST, dest_size); </P> <p >}</P> <p>
The question is, how do we open macro _ mmi_chset_gb2312 ???????
Let's take a look at the fragment in the features configuration file mmi_features.h of MKT.
/* <Br/> Description: Turn on simple Chinese gb2312 charset <br/> Option: [_ on __, _ off __, _ AUTO _] <br/> reference: sop_add_new_charset_conversion.doc <br/> */<br/> # define pai_mmi_chset_gb2312 (_ AUTO __)
[Doubt] the following definitions are available in the configuration file mmi_features_type.h:
/* General On/Off/auto type */
# DEFINE _ on _ (-1)
# DEFINE _ off _ (-2)
# DEFINE _ AUTO _ (-3)
Where _ AUTO _ does not know what it means ??????
Of course, if _ mmi_chset_gb2312 _ is not enable, we can directly use the mmi_chset_convert () function ()
The original function is as follows:
/*************************************** ************************************ <Br /> * function <br/> * mmi_chset_convert <br/> * description <br/> * convert string between 2 character sets. (will add the terminate character) <br/> * parameters <br/> * src_type [in] charset type of source <br/> * dest_type [in] charset type of destination <br/> * src_buff [in] buffer stores source string <br/> * dest_buff [out] buffer stores destination string <br/> * dest_size [in] size of destination buffer (bytes) <br/> * returns <br/> * length of destination string, including null Terminator. (bytes) <br/> ************************************ **************************************** */<br/> kal_int32 mmi_chset_convert (<br/> mmi_chset_enum src_type, <br/> mmi_chset_enum dest_type, <br/> char * src_buff, <br/> char * dest_buff, <br/> kal_int32 dest_size );
The usage is as follows:
Mmi_chset_convert (mmi_chset_gb2312, mmi_chset_ucs2, (char *) soure_string, (char *) destion_string, source_size );
This is method 1! Call MTK internal API
There is also Method 2:
You can directly convert the characters to be displayed to ucs2; you can obtain them from me for a small tool !!!
- S8 sprompt [] = "/x2d/x4e/XFD/x56/x00/x00 ";
- Displaypopup (pu8) sprompt, img_global_warning, 0, 1000, (u8) warning_tone );
PS:
Write the following TXT file and save it as HTML. Open it in a browser!
<SCRIPT type = "text/JavaScript">
Document. Write (Unescape ("% u738b % u5fc5 % u8d85 "));
</SCRIPT>