hi, how to convert LPCSTR to LPWSTR if UNICODE is #defined?
Thanks.
This is a discussion on LPCTSTR to LPWSTR within the Windows Programming forums, part of the Platform Specific Boards category; hi, how to convert LPCSTR to LPWSTR if UNICODE is #defined? Thanks....
hi, how to convert LPCSTR to LPWSTR if UNICODE is #defined?
Thanks.
Depends on what you want to do.
Do you simply want to pass a string literal such as "Hello, this is my string"?
If so, append L: L"Hello, this is my string".
If you want to do a conversion, it's slightly more difficult. Let me know what you want to do.
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^
or you can use TEXT macro - so your string literals will be converted automatically to the correct type depending on the defined/not defined UNICODE macro (or _UNICODE - I do not remember which...)
If I have eight hours for cutting wood, I spend six sharpening my axe.
If you're not talking about a string literal......
Well, your subject says "LPCTSTR to LPWSTR" and your post says "LPCSTR to LPWSTR" - so I'll awnser both.
"LPCSTR to LPWSTR"
MultiByteToWideChar() or mbstowcs()
"LPCTSTR to LPWSTR"
ggCode:LPCTSTR tsz; LPWSTR wsz; #if defined(UNICODE) || defined(_UNICODE) wsz = tsz; // or lstrcpyW() or wcscpy() #else // MultiByteToWideChar() or mbstowcs() #endif