将unicode下的wstring转化成ansi下的string
将unicode下的wstring转化成ansi下的string
饮水思源,不忘初心。 要面包,也要有诗和远方。
//将unicode下的wstring转化成ansi下的string
inline std::string UnicodeToASCII(LPCTSTR lpszText)
{
int length=_tcslen(lpszText);
TCHAR* pWideCharStr=new TCHAR;
char* data=new char;
_tcscpy(pWideCharStr, lpszText);
WideCharToMultiByte(CP_ACP, 0, pWideCharStr, -1, data, 2*length + 2, NULL, NULL);
std::string strText = data;
delete []data;
delete []pWideCharStr;
return strText;
}
页:
[1]