void Gb2312ToUtf8(const char *pcGb2312, std::string & strUtf8)
{
//wchar_t pcUnicode[CHAR_BUFSIZE];
//gb2312 to unicode
int nUnicodeLen = MultiByteToWideChar(CP_ACP, 0, pcGb2312, -1, NULL, 0);
wchar_t * pcUnicode = new wchar_t[nUnicodeLen+1];
memset(pcUnicode, 0, nUnicodeLen * 2 + 2);
MultiByteToWideChar(CP_ACP, 0, pcGb2312, -1, pcUnicode, nUnicodeLen);
//unicode to utf8
int nUtf8Len = WideCharToMultiByte(CP_UTF8, 0, pcUnicode, -1, NULL, 0, NULL, NULL);
char *pcUtf8=new char[nUtf8Len + 1];
memset(pcUtf8, 0, nUtf8Len + 1);
WideCharToMultiByte(CP_UTF8, 0, pcUnicode, -1, pcUtf8, nUtf8Len, NULL, NULL);
strUtf8=pcUtf8;
delete[] pcUtf8;
delete[] pcUnicode;
}
Gb2312转Utf8
原创
©著作权归作者所有:来自51CTO博客作者zhongguoren666的原创作品,请联系作者获取转载授权,否则将追究法律责任
下一篇:线程同步方法
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
gb2312编码文件转成utf8
将指定目录directory(包含子目录)下的指定后缀名为suffix的文件,统一从编码格式为fromEncoding更改为toEncoding ,比如gbk到utf-8,或者utf-8到gbk
gbk gb2312 utf-8 休闲 encoding