Convert OLECHAR * to CHAR * to create string ()
OLECHAR
- character string wchar_t
. I recommend reading The Complete Guide to C ++ Strings Part II - String Wrapping Classes .
source to share
OLECHAR*
- Unicode string (UTF-16) wchar_t
. If you want to convert it to a string CHAR*
, you should clarify what specific encoding you are going to use for the conversion.
For example, you can convert from UTF-16 to UTF-8 (this is a lossless conversion), and you can store the UTF-8 string in CHAR*
/ std::string
(I prefer to use reliable string classes instead of raw pointers in C ++ code).
To do the conversion, you can use the WideCharToMultiByte()
Win32 API. You can use the value CP_UTF8
"codepage" if you want to convert from UTF-16 to UTF-8. For "ANSI" (potentially lossy) conversion you can use CP_ACP
etc.
(There are also handy ATL wrappers for the aforementioned Win32 API, for example CW2A
, but I'm not sure what level of functionality is available in the VC6 version of those wrappers.)
source to share