辅助开发模块

//GKB 转换UTF8

//-----------------------------字符转换----------------------------------------------------------------------
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
std::string Win32GBKToUTF8(c_char* pStr)
{
std::string str = pStr;
std::string strOutUTF8 = "";
WCHAR * str1;
int n = MultiByteToWideChar(CP_ACP, 0, pStr, -1, NULL, 0);
str1 = new WCHAR[n];
MultiByteToWideChar(CP_ACP, 0, pStr, -1, str1, n);
n = WideCharToMultiByte(CP_UTF8, 0, str1, -1, NULL, 0, NULL, NULL);
char * str2 = new char[n];
WideCharToMultiByte(CP_UTF8, 0, str1, -1, str2, n, NULL, NULL);
strOutUTF8 = str2;
delete[]str1;
str1 = NULL;
delete[]str2;
str2 = NULL;
return strOutUTF8;
}
#endif
//

posted @ 2017-01-14 17:43  贝贝潘  阅读(191)  评论(0编辑  收藏  举报