Using Generic-Text Mappings
For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.
To simplify code development for various international markets, the Microsoft run-time library provides Microsoft-specific "generic-text" mappings for many data types, routines, and other objects. These mappings are defined in TCHAR.H. You can use these name mappings to write generic code that can be compiled for any of the three kinds of character sets: ASCII (SBCS), MBCS, or Unicode, depending on a manifest constant you define using a
#define statement. Generic-text mappings are Microsoft extensions that are not ANSI compatible.
|None (the default: neither ||SBCS (ASCII)|
For example, the generic-text function
_tcsrev, defined in TCHAR.H, maps to
MBCS has been defined in your program, or to
_UNICODE has been defined. Otherwise
_tcsrev maps to
The generic-text data type
_TCHAR, also defined in TCHAR.H, maps to type
_MBCS is defined, to type
_UNICODE is defined, and to type
char if neither constant is defined. Other data type mappings are provided in TCHAR.H for programming convenience, but
_TCHAR is the type that is most useful.
|Generic-text data type name||SBCS (_UNICODE, _MBCS not defined)||_MBCS defined||_UNICODE defined|
|No effect (removed by preprocessor)||No effect (removed by preprocessor)|
For a complete list of generic-text mappings of routines, variables, and other objects, see Generic-Text Mappings.
The following code fragments illustrate the use of
_tcsrev for mapping to the MBCS, Unicode, and SBCS models.
_TCHAR *RetVal, *szString; RetVal = _tcsrev(szString);
MBCS has been defined, the preprocessor maps the preceding fragment to the following code:
char *RetVal, *szString; RetVal = _mbsrev(szString);
_UNICODE has been defined, the preprocessor maps the same fragment to the following code:
wchar_t *RetVal, *szString; RetVal = _wcsrev(szString);
_UNICODE has been defined, the preprocessor maps the fragment to single-byte ASCII code, as follows:
char *RetVal, *szString; RetVal = strrev(szString);
Thus you can write, maintain, and compile a single source code file to run with routines that are specific to any of the three kinds of character sets.
END Microsoft Specific