Can any one tell me how to convert CString to std::wstring
A:
CString s;
std::wstring s1 = s;
This should work as CString has operator LPCTSTR()
defined.
Naveen
2010-01-11 10:48:55
Why use a C cast for that? A fellow-worker of mine once was in the position that he had to find explicit casts, as some of them didn't work on the platform he needed to port a 4MLoC project to. He praised everyone who used C++' explicit casts (you can grep for them) and fought hard to ban all C-style casts, since they were so hard to find.
sbi
2010-01-11 11:10:30
+1
A:
CString hi("Hi");
std::wstring hi2(hi);
to go the other way, use c_str()
std::wstring hi(L"Hi");
CString hi2(hi.c_str());
DanDan
2010-01-11 10:52:05