- 注册时间
- 2021-4-16
- 最后登录
- 2023-8-13
- 在线时间
- 4 小时
编程入门
- 龙马币
- 48
|
GBK转UTF-8代码 char* GBKToUTF8(const char* strGBK)
- char* GBKToUTF8(const char* strGBK)
- {
- int len=MultiByteToWideChar(CP_ACP, 0, (LPCTSTR)strGBK, -1, NULL,0);
- unsigned short * wszUtf8 = new unsigned short[len+1];
- memset(wszUtf8, 0, len * 2 + 2);
- MultiByteToWideChar(CP_ACP, 0, (LPCTSTR)strGBK, -1, (LPWSTR)wszUtf8, len);
- len = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)wszUtf8, -1, NULL, 0, NULL, NULL);
- char *szUtf8=new char[len + 1];
- memset(szUtf8, 0, len + 1);
- WideCharToMultiByte (CP_UTF8, 0, (LPCWSTR)wszUtf8, -1, (LPSTR)szUtf8, len, NULL,NULL);
- return szUtf8;
- }
复制代码
|
|