将字符串转换为wchar_t(宽字符)C ++

时间:2013-02-12 01:27:09

标签: c++

我想知道如何将string str = "whatever"转换为wchar_t,以便将字符串存储为wchar_t chResponse[] = ...(converted from string)..

我正在尝试以下代码:

string str = "whatever";
std::wstring_convert<std::codecvt_utf8<wchar_t>> utf8conv;
auto w_result = utf8conv.from_bytes(str); // convert utf8 to wchar_t
wchar_t chResponse[] = w_result;

它给了我这个错误:

error C2075: 'chResponse' : array initialization needs curly braces

0 个答案:

没有答案