Jump to content

C++ Language/Std/Strings/Unicode

From Wikibooks, open books for an open world

An 8-bit "Ascii character" has type char (its literal values are char cVar = 'h'; and "hello", its Standard Library functions are named like strlen(), and its Win32 functions are named like SetWindowTextA()).

A "wide-Unicode character" has type wchar_t (its literal values are wchar_t cwVar = L'h'; and L"hello", its Standard Library functions are named liked wcslen(), and its Win32 functions are named like SetWindowTextW()).

Windows programmers use preprocessor macros in TCHAR cxVar = _TEXT('h'); to alias either char cxVar = 'h'; or wchar_t cxVar = L'h'; (these macros are controlled by Windows' build system). That same switching mechanism also controls the expansion of macros _tcslen() and SetWindowText().

Additional information about Unicode