Platform SDK: International Features |
The standard C run-time libraries contain wide-character versions of the ANSI string functions that begin with the letters str. The wide-character versions of the functions start with the letters wcs (or sometimes _wcs). The Unicode data type is compatible with the wide-character data type wchar_t in ANSI C; this allows access to the wide-character string functions.
Generic functions exist for all standard C string functions. They start with the letters _tcs and are listed in the Tchar.h header file. These functions use the generic data types TCHAR and TCHAR*
An application must add the following lines to its program in order to use the generic functions and compile for Unicode:
#define _UNICODE #include <tchar.h> #include <wchar.h>
Note that both the Tchar.h and Wchar.h are required, and that the leading underscore on the _UNICODE variable is also required.
The wcstombs and mbstowcs functions can convert from the character set supported by the standard C library to Unicode and back, with some limitations. For more information about translating strings to and from Unicode, see Translation Between String Types.
The printf function defined in Tchar.h supports the same format specifications as wsprintf; for details, see String Functions. Similarly, Tchar.h contains a wprintf function, in which the format string itself is a Unicode string.