据统计90%查看本帖的人,都已经注册本站了哦
您需要 登录 才可以下载或查看,没有账号?立即注册
×
string UTF8ToGB2132(string strSrc)
{
string result;
WCHAR *wstrSrc = NULL;
char *szRes = NULL;
int i;
// UTF8转换成Unicode
i = MultiByteToWideChar(CP_UTF8, 0, strSrc.c_str(), -1, NULL, 0);
wstrSrc = new WCHAR[i + 1];
MultiByteToWideChar(CP_UTF8, 0, strSrc.c_str(), -1, wstrSrc, i);
// Unicode转换成GB2312
i = WideCharToMultiByte(CP_ACP, 0, wstrSrc, -1, NULL, 0, NULL, NULL);
szRes = new char[i + 1];
WideCharToMultiByte(CP_ACP, 0, wstrSrc, -1, szRes, i, NULL, NULL);
result = string(szRes);
if (wstrSrc != NULL)
{
delete[]wstrSrc;
wstrSrc = NULL;
}
if (szRes != NULL)
{
delete[]szRes;
szRes = NULL;
}
return result;
}
喜欢C++ win32的一起交流啊
|