I know it’s simple question, but I have tried so many approaches, in all of them I lose data, text data, not those trailing 0’s after each byte.
I converted CString to wchar_t using GetBuffer(0), still no luck. I can’t get a proper LPBYTE.
At end I need it to be const LPBYTE, but I think with a simple casting of LPBYTE I can get const LPBYTE.
So could you help me to convert CString or wchar_t to LPBYTE array?
Thanks
If you want to “see” the content of a
CStringas a simple “raw” sequence (array) ofBYTE‘s, you can useCString::GetString()method to get the pointer to the firstCStringcharacter, and then cast toconst BYTE*:If you want to “see” a single
wchar_tas a sequence ofBYTE‘s, you can take its address and again cast toconst BYTE*:But if you want to convert from Unicode UTF-16 to another encoding like UTF-8, you may want to use some conversion helpers like
CW2A: