How can I convert from CString
to std::wstring
?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
To convert CString
to std::wstring
:
CString hi("Hi");
std::wstring hi2(hi);
And to go the other way, use c_str()
:
std::wstring hi(L"Hi");
CString hi2(hi.c_str());
回答2:
Try this:
std::wstring strString((LPCTSTR)strCString);
回答3:
This should work as CString
has operator LPCTSTR()
defined:
CString s;
std::wstring s1 = s;