多字符串向宽字符的转换(MultiByteToWideChar的示例)
2012-07-20 10:11
519 查看
多字符串向宽字符的转换(MultiByteToWideChar的示例)
char buffer[4096] = {0};
#ifdef _UNICODE
//返回所需的短字符数组空间的个数
DWORD dwNum = MultiByteToWideChar (CP_ACP, 0, buffer, -1, NULL, 0);
wchar_t *pwText;
pwText = new wchar_t[dwNum];
if(!pwText)
{
delete []pwText;
return;
}
MultiByteToWideChar (CP_ACP, 0, buffer, -1, pwText, dwNum);// 开始转换
AfxMessageBox(pwText);// 输出
delete []pwText; //使用完毕当然要记得释放占用的内存:
#else
AfxMessageBox(buffer);// 输出
#endif
本文来自:我爱研发网(52RD.com) - R&D大本营
详细出处:http://www.52rd.com/Blog/Detail_RD.Blog_ipgbear_10116.html
char buffer[4096] = {0};
#ifdef _UNICODE
//返回所需的短字符数组空间的个数
DWORD dwNum = MultiByteToWideChar (CP_ACP, 0, buffer, -1, NULL, 0);
wchar_t *pwText;
pwText = new wchar_t[dwNum];
if(!pwText)
{
delete []pwText;
return;
}
MultiByteToWideChar (CP_ACP, 0, buffer, -1, pwText, dwNum);// 开始转换
AfxMessageBox(pwText);// 输出
delete []pwText; //使用完毕当然要记得释放占用的内存:
#else
AfxMessageBox(buffer);// 输出
#endif
本文来自:我爱研发网(52RD.com) - R&D大本营
详细出处:http://www.52rd.com/Blog/Detail_RD.Blog_ipgbear_10116.html
相关文章推荐
- 关于MultiByteToWideChar与WideCharToMultiByte代码测试(宽字符与多字节字符的转换)以及字符串的转换代码测试
- 用MultiByteToWideChar和WideCharToMultiByte进行短字符和宽字符之间的转换
- ANIS与UNICODE字符格式转换:MultiByteToWideChar() 和WideCharToMultiByte() 函数
- Windows,C/C++_字符串转换_MultiByteToWideChar和WideCharToMultiByte的正确使用方法及参数详解
- MultiByteToWideChar和WideCharToMultiByte的正确使用方法及参数详解,实现字符编码转换、宽字符和字符的转换
- MultiByteToWideChar和MultiByteToWideChar对各种字符编码间的转换
- Wince 字符转换(WideCharToMultiByte和MultiByteToWideChar)方法
- Delphi与字符编码(实战篇)(MultiByteToWideChar会返回转换后的宽字符串长度)
- ANIS与UNICODE字符格式转换:MultiByteToWideChar()和WideCharToMultiByte()函数介绍
- 用MultiByteToWideChar和WideCharToMultiByte进行短字符和宽字符之间的转换
- UNICODE和ANSI字符串的转换(解释了MultiByteToWideChar,WideCharToMultiByte,GetTextCharsetInfo,GetTextCharset,IsDBCSLeadByte,IsDBCSLeadByteEx,IsTextUnicode一共7个函数)
- 字符串转换:wchar_t MultiByteToWideChar Unicode等
- Java中char数组(字符数组)与字符串String类型的转换方法
- Delphi 的字符及字符串[2] - Char、AnsiChar、WideChar、PChar、PAnsiChar、PWideChar
- Delphi 的字符及字符串 - Char、AnsiChar、WideChar、PChar、PAnsiChar、PWideChar
- VC++中通过MultiByteToWideChar将string|char*转换为wstring|wchar_t*
- String字符串与字符(char类型)数组互相转换
- Delphi的字符及字符串-Char、AnsiChar、WideChar、PChar、PAnsiChar、PWideChar
- Cocos2d-x程序Windows下VC中文乱码的解决(用MultiByteToWideChar进行转换,VC2010有非常厉害的execution_character_set)
- 多字节转换MultiByteToWideChar和WideCharToMultiByte使用小结