On Windows, APIs that take char *
use the current code page whereas wchar_t *
APIs use UTF-16. As a result, you should always use wchar_t
on Windows. A recommended way to do this is to:
// Be sure to define this BEFORE including <windows.h>
#define UNICODE 1
#include <windows.h>
When UNICODE
is defined, APIs like SetWindowText
will be aliased to SetWindowTextW
and can therefore be used safely. Without UNICODE
, SetWindowText
will be aliased to SetWindowTextA
and therefore cannot be used without first converting to the current code page.
However, there's no good reason to use wchar_t
when you are not calling Windows APIs, since its portable functionality is not useful, and its useful functionality is not portable (wchar_t
is UTF-16 only on Windows, on most other platforms it is UTF-32, what a total mess.)