MFC - How to convert WCHAR to CString?

amiltonjr picture amiltonjr · Jul 3, 2014 · Viewed 8.8k times · Source

Is it possible to convert WCHAR to CString? I need to do that, or even convert it to char or char*.

Thanks!

Answer

Remy Lebeau picture Remy Lebeau · Jul 3, 2014

CString has constructors and assignment operators that accept char* and wchar_t* data as input. So you can assign them directly to CString.

If you want to convert wchar_t* to char* look at WideCharToMultiByte()