
Using the Win32 API, you can write programs so that they can be compiled to work
with some 8-bit encoding (the system’s “code page”) or with wide characters. In C or
C++ programming, you can define the constant (macro) _UNICODE to be 1 (true) or 0
(false) depending on whether you want wide characters or not. You would then declare
your character variables for being of type TCHAR, which expands to wchar_t or (8-bit)
char, depending on the setting of UNICODE. Similarly, you would declare a pointer to a
character (or to a string) as being of type LPTSTR. It expands to wchar_t * or char *,
again depending on _UNICODE. You can also use the name LPWSTR, which unambiguously
means a pointer to a string of wide characters—i.e., wchar_t *. Win32 APIs that operate
on text (strings) exist in two versions:
“A” versions (code page versions)
These versions operate on 8-bit characters, according to the code page currently
in use, such as windows-1252 (Windows Latin 1). The letter “A” reminds us of the
misnomer “ANSI.”
“W” versions (Unicode versions)
These versions operate on wide—i.e., 16-bit—characters, or UTF-16 code units,
to be exact.
For ease of programming, you can use generic names that will be resolved to “A” or
“W” versions during compilation, depending on the setting of _UNICODE. For example,
if you call a function with the name SetWindowText, it will be resolved to the name
SetWindowTextW when _UNICODE ...