UTF8ToGB

 
int UTF8ToGB(const char* str,char *out)
{
 WCHAR *strSrc;
 TCHAR *szRes;
 int len;
 
 //获得临时变量的大小
 int i = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);
 strSrc = new WCHAR[i+1];
 MultiByteToWideChar(CP_UTF8, 0, str, -1, strSrc, i);
 
 //获得临时变量的大小
 i = WideCharToMultiByte(CP_ACP, 0, strSrc, -1, NULL, 0, NULL, NULL);
 szRes = new TCHAR[i+1];
 WideCharToMultiByte(CP_ACP, 0, strSrc, -1, szRes, i, NULL, NULL);
 
 len = (i+1)*sizeof(CHAR);
 memcpy(out,szRes,len);
 out[len+1] ='\0';
 
 delete []strSrc;
 delete []szRes;
 
 return len;
}

你可能感兴趣的:(null,delete)