c++
wstring转string
与string转wstring
string ws2s(const wstring& ws) {
const char* curLocale = setlocale(LC_ALL, NULL);
setlocale(LC_ALL, "en_US.UTF-8");
size_t _Dsize = 4 * ws.size() + 1;
char *_Dest = new char[_Dsize];
memset(_Dest, 0, _Dsize);
wcstombs(_Dest, ws.c_str(), _Dsize);
string result = _Dest;
delete []_Dest;
setlocale(LC_ALL, curLocale);