String encoding Chinese expressions commonly used are: Gb2312,gbk,unicode,utf-8
Where GBK is a superset of GB2312, which covers all GB2312 encoded content,
UTF-8 is an encoding format for Unicode in network transmission,
If we use VC as a development tool, under win to develop, then win
The default character set is GBK, and the Symbian system default encoding is
Unicode, which means that characters written directly inside the program are displayed on the phone,
It will become garbled.
There are two common ways to solve this problem:
(1) static resource file solution
(2) dynamic calling character Set conversion function solution
Yes, yes. The first solution, you need to manually edit the RSS file, the part of the Chinese character content to UTF-8 format,
Add at the end or beginning of the RSS file: Character_set UTF8
The disadvantage is that this type of string is generally targeted at static resources, and if it is the kind that updates Chinese characters based on data changes
You need to consider the second case
The second way to dynamically convert character sets
The two classes of ccnvcharactersetconverter and cnvutfconverter are often used to convert to the Unicode encoding recognized by the Symbian system.
The Ccnvcharactersetconverter class can perform all encoding conversions supported by Symbian
Cnvutfconverter This class often UTF-8 with the conversion of Unicode and UTF-7 to Unicode
Add header File
#include <charconv.h>//For char set convert Gbk-unicode
Add in MMP
LIBRARY charconv.lib//For GBK to Unicode Converter
After these two steps have been completed, the following two functions are ready to be recompiled.
void Cmcappui::convgbk2uni (tdesc8& original, tdes& res) {
#ifndef __wins__
RFs afileserversession;
Afileserversession.connect ();
ccnvcharactersetconverter* CONVERTER=CCNVCHARACTERSETCONVERTER::NEWLC ();
if (CONVERTER->PREPARETOCONVERTTOORFROML (kcharactersetidentifiergbk,afileserversession)! = ccnvcharactersetconverter::eavailable)
User::leave (kerrnotsupported);
Specific Use methods:
Tbuf8<20> Title8;
Tbuf<20> Title16;
Tbuf8<20> Msg8;
Tbuf<20> Msg16;
Title8. Format (_L8 ("Friendship hint"));
Convgbk2uni (Title8, TITLE16);
Msg8. Format (_L8 ("Thank you for your use");
Convgbk2uni (Msg8, MSG16);
Showinfodialog (Title16, MSG16);
Now, Title16 and MSG16 are all stored in a 16-bit Unicode Chinese string,
can be displayed directly.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.