1、std::wstring 转 std::string
1 string WstringToString(const std::wstring wstr)
2 {
3 #if 1
4 std::string result;
5 int len = WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), wstr.size(), NULL, 0, NULL, NULL);
6 if( len <= 0 )
7 return result;
8
9 char* buffer = new char[len + 1];
10 if(buffer == NULL )
11 return result;
12
13 WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), wstr.size(), buffer, len, NULL, NULL);
14 buffer[len] = '