If the system region is non-Chinese (for example, English), multibytetowidechar fails to be executed.

Source: Internet
Author: User

Source Address: http://www.wangchao.net.cn/bbsdetail_63339.html

Problem description:

When both the Chinese font and environment are set in wince, but the system area is not Chinese (for example, English), the execution of multibytetowidechar fails.
Solution Process:
The first is the method used previously:
Uint wchar2char (lpcwstr pwszsrc, lpstr pszdst)
{
Return widechartomultibyte (cp_acp, 0, pwszsrc,-1, pszdst, max_path, null, null );
}
Uint char2wchar (lpcstr pszsrc, lpwstr pwszdst)
{
Return multibytetowidechar (cp_acp, 0, pszsrc,-1, pwszdst, max_path );
}
Running char2wchar in the description environment does not always fail. The built-in character conversion is no problem, for example:
Char s [10] = "test ";
Tchar ws [10];
Char2wchar (S, WS );
It is estimated that the char has been converted to Unicode during EVC compilation, or the codePage is already 936 during compilation. for specific reasons, you need to debug it. If you are interested, you can perform experiments on your own.
An error occurs when a string is read from the database and converted. Because the real ANSI is read from the database at this time, it is different from the above. In this case
Debug char2wchar and you will find that the conversion fails. The following is the result of EVC tracking. The first column is an ANSI string, and the second column is a character that can be converted normally when the region is Chinese.
String, the third column is the string converted in the English environment, the string is the word "Administrator:
Chinese ansirpcen
Tube b9dc7ba100b9 00dc
C0ed740600c0 00ed
Member d4b1545800d4 00b1
As you can see, in the last case, the conversion result is only some simple transformations and is not transferred out. What is the reason, mainly because of the first parameter of widechartomultibyte?
CodePage. For example, cp_acp previously used indicates that the system character set is used for conversion. However, because the system character set is in English
There are Chinese characters, so the conversion fails, so the final answer is very simple:
Uint wchar2char (lpcwstr pwszsrc, lpstr pszdst)
{
Return widechartomultibyte (936, 0, pwszsrc,-1, pszdst, max_path, null, null );
}
Uint char2wchar (lpcstr pszsrc, lpwstr pwszdst)
{
Return multibytetowidechar (936, 0, pszsrc,-1, pwszdst, max_path );
}
Finally, let's look at the definition of codePage:
  
Definition
Description
  
874
Thai
  
932
Japan
  
936
Chinese (PRC, Singapore)
  
949
Korean
  
950
Chinese (Taiwan; Hong Kong SAR, PRC)
  
1200
Unicode (BMP of iso0 10646)
  
1250
Windows 3.1 Eastern European
  
1251
Windows 3.1 Cyrillic
  
1252
Windows 3.1 Latin 1 (US, Western Europe)
  
1253
Windows 3.1 Greek
  
1254
Windows 3.1 Turkish
  
1255
Hebrew
  
1256
Arabic
  
1257
Baltic

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.