I want to convert CString
to WCHAR*
or std::string
to WCHAR*
in Visual Studio C++ MFC Application. I found in stackoverflow that it only has the solution for convert to wchar_t*
.
Please help me. Thank you!
I want to convert CString
to WCHAR*
or std::string
to WCHAR*
in Visual Studio C++ MFC Application. I found in stackoverflow that it only has the solution for convert to wchar_t*
.
Please help me. Thank you!
When you use CString, you could access the CW2A ATL macro,which converts CString to string.
CString theCStr;
std::string STDStr( CW2A( theCStr.GetString(), CP_UTF8 ) );
Or refer to this document.
I believe CString
class can do such conversion:
CStringA a = "ANSI";
CStringW w(a);