I am aware that normally you do not need wchar_t
to support unicode for general purpose code, however, the Windows API seems to have a ASCII or Wide Character equivalent of all methods that take a string. For example:
FindWindowA(nullptr, "File Explorer"); // ASCII version
FindWindowW(nullptr, L"File Explorer"); // Wide Character version
I compile with Visual Studio 2017
using the following option in Properties > General
:
Character Set: Use Unicode Character Set
The other available option is: Use Multi-Byte Character Set
.
I want to be able to support filenames with unicode characters, and I am not sure if I should compile with the multi-byte
character set and use all the Wide Character methods, or if I should compile with the unicode
character set and use all the ASCII methods.
I am not sure if I should compile with the multi-byte character set and use all the Wide Character methods, or if I should compile with the unicode character set and use all the ASCII methods.
wchar_t
.char
.MultiByteToWideChar(CP_ACP)
, call their "W" counterpart, and finally transform the result back into multi-byte using WideCharToMultiByte(CP_ACP)
.Thus, I would advise you to use the "W" version of the functions assuming you are coding for Windows NT and above.
In the context of the Win32 API, Microsoft's "Unicode" generally refers to UTF-16. Also Microsoft's MBCS is essentially DBCS and for Windows 9x operating systems, the "W" version of the functions are missing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With