void QString2ANSI(QString text, char **pOut)
{
std::wstring wIn = text.toStdWString();
char *pcstr = (char *)malloc(sizeof(char)*(2 * wcslen(wIn.c_str())+1));
memset(pcstr , 0 , 2 * wcslen(wIn.c_str())+1 );
int len = WideCharToMultiByte(CP_ACP, NULL, wIn.c_str(), wcslen(wIn.c_str()), NULL, 0, NULL, NULL);
*pOut = (char *)oef_crt_malloc(len + 1);
WideCharToMultiByte(CP_ACP, NULL, wIn.c_str(), wcslen(wIn.c_str()), *pOut, len, NULL, NULL);
(*pOut)[len] = '\0';
}
包含中文的QString 转 char*
最新推荐文章于 2022-12-16 17:24:59 发布