Home > Blockchain >  How can I convert CString to WCHAR* and std::string to WCHAR* in C , not wchar_t*
How can I convert CString to WCHAR* and std::string to WCHAR* in C , not wchar_t*

Time:01-20

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!

CodePudding user response:

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.

CodePudding user response:

I believe CString class can do such conversion:

CStringA a = "ANSI";
CStringW w(a);
  •  Tags:  
  • Related