C++ Ansi转Unicode - Unicode转Ansi源码
C++ Ansi转Unicode - Unicode转Ansi源码
ANSI转unicode
//ANSI转unicode
wchar_t* AnsiToUnicode(char *str)
{
DWORD dwNum = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
wchar_t *pwText;
pwText = new wchar_t;
if(!pwText)
{
delete []pwText;
}
MultiByteToWideChar (CP_ACP, 0, str, -1, pwText, dwNum);
return pwText;
}wchar_t *strUnicode = AnsiToUnicode(str);
OutputDebugStringW(strUnicode);
Unicode转ansi
//Unicode转ansi
wchar_t wText = {L"宽字符转换实例!"};
DWORD dwNum = WideCharToMultiByte(CP_OEMCP,NULL,wText,-1,NULL,0,NULL,FALSE);
char *psText;
psText = new char;
if(!psText)
{
delete []psText;
}
WideCharToMultiByte (CP_OEMCP,NULL,wText,-1,psText,dwNum,NULL,FALSE);
delete []psText;
页:
[1]