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

来源:互联网 发布:酒店经营数据分析 编辑:程序博客网 时间:2024/06/05 15:35

由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();



阅读全文
0 0
原创粉丝点击