const std::string转换为const wchar_t* string

由const std::string转换为const wchar_t* string

c++代码:

const std::string text = "汉语";

std::wstring szDst;
		{
			int len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)text.c_str(), -1, NULL, 0);
			wchar_t *wszUtf8 = new wchar_t[len + 1];
			memset(wszUtf8, 0, len * 2 + 2);
			MultiByteToWideChar(CP_ACP, 0, (LPCSTR)text.c_str(), -1, (LPWSTR)wszUtf8, len);
			szDst = wszUtf8;
			delete[]wszUtf8;
		}
const wchar_t* string result = 
szDst.c_str();
 
  



你可能感兴趣的:(C/C++,STL等相关技术,Win32技术开发,C++,MFC)