{
Int unicodeLen=MultiByteToWideChar (sourceStr CP_UTF8, 0, 1, NULL, 0).
Would be * pUnicode;
PUnicode=new would [unicodeLen + 1];
(unicodeLen memset (pUnicode, 0, + 1) * sizeof (would));
Int nRet=MultiByteToWideChar (sourceStr CP_UTF8, 0, 1, pUnicode, unicodeLen);
If (nRet & lt;=0)
{
MessageBox (" conversion failure ", "");
}
The else
{
MessageBox (" into ", "");
}
Char * pTargetData=https://bbs.csdn.net/topics/NULL;
Int targetLen=WideCharToMultiByte (pUnicode CP_ACP, 0, 1, pTargetData, 0, NULL, FALSE);
PTargetData=https://bbs.csdn.net/topics/new char [targetLen + 1];
Memset (pTargetData, 0, targetLen + 1);
NRet=WideCharToMultiByte (pUnicode CP_ACP, 0, 1, pTargetData, targetLen, NULL, FALSE);
If (nRet & lt;=0)
{
MessageBox (" conversion failure \ n ", "");
}
The else
{
MessageBox (" \ n transformation success ", "");
}
}
Try the WideCharToMultiByte (
Used the following parameters:
# define CP_OEMCP
# define CP_MACCP
# define CP_THREAD_ACP
# define CP_SYMBOL
1258 - the code page
Consult everybody a great god, thank you
CodePudding user response:
1. Used WideCharToMultiByte for size, called again after conversion, '\ 0' at the end of how to keep one size;2. The control panel is set.
3. Use a function iconv (to CP1258 (the code), always transcoding failure? I do not know from_charset, to_charset what are good?
5. Use the setlocale (LC_ALL, "regional Settings and code page Settings"), "the locale and code page Settings" tried the code "1258" ", transcoding don't come out?
Helpless, consult everybody a great god? Thank you
CodePudding user response:
MultiByteToWideChar (CP_UTF8 first turn to the UNICODEWideCharToMultiByte ( 1258 , turn to the article (don't CP_ACP)
CodePudding user response:
Void UTF8Convert (char sourceStr []){
Int unicodeLen=MultiByteToWideChar (sourceStr CP_UTF8, 0, 1, NULL, 0).
WCHAR * pUnicode;
PUnicode=new WCHAR [unicodeLen + 1];
(unicodeLen memset (pUnicode, 0, + 1) * sizeof (WCHAR));
MultiByteToWideChar (sourceStr CP_UTF8, 0, 1, pUnicode, unicodeLen);
BYTE * pTargetData=https://bbs.csdn.net/topics/NULL;
Int targetLen=WideCharToMultiByte (1258, 0, (LPWSTR pUnicode), 1, (char *) pTargetData, 0, NULL, NULL);
PTargetData=https://bbs.csdn.net/topics/new BYTE [targetLen + 1];
Memset (pTargetData, 0, targetLen + 1);
WideCharToMultiByte (1258, 0, (LPWSTR pUnicode), 1, (char *) pTargetData, targetLen, NULL, NULL);
}
1. Test the article: Lo? I th? M: VIETTEL? Nh gia: 50000 S? Begawan: 10001933541909 M? T kh? U: 710164507867986 Tr? Ng Thai: Hoan thanh
Where is the result of the great god see my debugging, code written wrong, also exists the question mark, thank you
CodePudding user response:
Use the WideCharToMultiByte (1258, the great god please see me the result of debugging, code where write wrong, invalid characters in the string?CodePudding user response:
Where can I see?? Support the article, according to the font? Written to a file see hexadecimal data correct?CodePudding user response:
VC2017debug mode seeWhat does display font support the article? thank you