字符串转换

来源:互联网 发布:2016淘宝热卖行业 编辑:程序博客网 时间:2024/05/19 02:21
char * CProcessUpdate::utf82gbk( char* strbuf )
{
 //utf-8转为Unicode
 int size = MultiByteToWideChar(CP_UTF8, 0, strbuf, -1, NULL, 0);
 WCHAR *strUnicode = new WCHAR[size];
MultiByteToWideChar(CP_UTF8, 0, strbuf, -1, strUnicode, size);

 //Unicode转换成UTF-8;
int i = WideCharToMultiByte(CP_ACP, 0, strUnicode, -1, NULL, 0, NULL, NULL);
char *strGBK = new char[i];
 WideCharToMultiByte(CP_ACP, 0, strUnicode, -1, strGBK, i, NULL, NULL);
 return strGBK;
}
原创粉丝点击