-
- string UTF8ToGB2132(string strSrc)
- {
- string result;
- WCHAR *wstrSrc = NULL;
- char *szRes = NULL;
- int i;
-
-
- 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);
-
-
- 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;
- } 出处:http://blog.csdn.net/tangaowen/article/details/6158984
posted @
2013-07-28 20:03
stma
阅读(
377)
评论()
收藏
举报