Reputation: 3299
How can I convert from CString
to std::wstring
?
Upvotes: 17
Views: 41447
Reputation: 895
CString s = _T("Привет");
USES_CONVERSION;
std::wstring ws(A2W((LPCTSTR)s));
Upvotes: 0
Reputation: 10562
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());
Upvotes: 28
Reputation: 73493
This should work as CString
has operator LPCTSTR()
defined:
CString s;
std::wstring s1 = s;
Upvotes: 2