C/C++ code#include <Windows.h>
#define CODE_PAGE_GB18030 54936
int Unicode2GBK( wchar_t *pUnicode, char** ppDest)
{
// get the size of the dest string
const int size = ::WideCharToMultiByte( CODE_PAGE_GB18030,
0/* you can do more for it*/, pUnicode, -1, 0, 0, 0, 0 );
if ( size == 0 )
{
return -1;
}
char* pDestString = new char[size + 2];
::memset( pDestString, 0, sizeof(pDestString) );
// transform
int ret = ::WideCharToMultiByte( CODE_PAGE_GB18030, 0, pUnicode, -1, pDestString, size, 0, 0 );
if( ret == 0 )
{
delete pDestString;
return -1;
}
else
{
*ppDest = pDestString;
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载
- 1
- 2
前往页