You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To simplify the transporting of code for international use, the Microsoft run-time library provides Microsoft-specific generic-text mappings for many data types, routines, and other objects. You can use these mappings, which are defined in Tchar.h, to write generic code that can be compiled for single-byte, multibyte, or Unicode character sets, depending on a manifest constant that you define by using a `#define` statement. Generic-text mappings are Microsoft extensions that are not ANSI compatible.
10
+
To simplify the transporting of code for international use, the Microsoft run-time library provides Microsoft-specific generic-text mappings for many data types, routines, and other objects. You can use these mappings, which are defined in tchar.h, to write generic code that can be compiled for single-byte, multibyte, or Unicode character sets, depending on a manifest constant that you define by using a `#define` statement. Generic-text mappings are Microsoft extensions that are not ANSI compatible.
11
11
12
-
By using the Tchar.h, you can build single-byte, Multibyte Character Set (MBCS), and Unicode applications from the same sources. Tchar.h defines macros (which have the prefix `_tcs`) that, with the correct preprocessor definitions, map to `str`, `_mbs`, or `wcs` functions, as appropriate. To build MBCS, define the symbol `_MBCS`. To build Unicode, define the symbol `_UNICODE`. To build a single-byte application, define neither (the default). By default, `_MBCS` is defined for MFC applications.
12
+
By using the tchar.h, you can build single-byte, Multibyte Character Set (MBCS), and Unicode applications from the same sources. tchar.h defines macros (which have the prefix `_tcs`) that, with the correct preprocessor definitions, map to `str`, `_mbs`, or `wcs` functions, as appropriate. To build MBCS, define the symbol `_MBCS`. To build Unicode, define the symbol `_UNICODE`. To build a single-byte application, define neither (the default). By default, `_MBCS` is defined for MFC applications.
13
13
14
-
The `_TCHAR` data type is defined conditionally in Tchar.h. If the symbol `_UNICODE` is defined for your build, `_TCHAR` is defined as **wchar_t**; otherwise, for single-byte and MBCS builds, it is defined as **char**. (**wchar_t**, the basic Unicode wide-character data type, is the 16-bit counterpart to an 8-bit signed **char**.) For international applications, use the `_tcs` family of functions, which operate in `_TCHAR` units, not bytes. For example, `_tcsncpy` copies `n``_TCHARs`, not `n` bytes.
14
+
The `_TCHAR` data type is defined conditionally in tchar.h. If the symbol `_UNICODE` is defined for your build, `_TCHAR` is defined as **wchar_t**; otherwise, for single-byte and MBCS builds, it is defined as **char**. (**wchar_t**, the basic Unicode wide-character data type, is the 16-bit counterpart to an 8-bit signed **char**.) For international applications, use the `_tcs` family of functions, which operate in `_TCHAR` units, not bytes. For example, `_tcsncpy` copies `n``_TCHARs`, not `n` bytes.
15
15
16
16
Because some Single Byte Character Set (SBCS) string-handling functions take (signed) `char*` parameters, a type mismatch compiler warning results when `_MBCS` is defined. There are three ways to avoid this warning:
17
17
18
-
1. Use the type-safe inline function thunks in Tchar.h. This is the default behavior.
18
+
1. Use the type-safe inline function thunks in tchar.h. This is the default behavior.
19
19
20
-
1. Use the direct macros in Tchar.h by defining `_MB_MAP_DIRECT` on the command line. If you do this, you must manually match types. This is the fastest method, but is not type-safe.
20
+
1. Use the direct macros in tchar.h by defining `_MB_MAP_DIRECT` on the command line. If you do this, you must manually match types. This is the fastest method, but is not type-safe.
21
21
22
-
1. Use the type-safe statically linked library function thunks in Tchar.h. To do so, define the constant `_NO_INLINING` on the command line. This is the slowest method, but the most type-safe.
22
+
1. Use the type-safe statically linked library function thunks in tchar.h. To do so, define the constant `_NO_INLINING` on the command line. This is the slowest method, but the most type-safe.
23
23
24
24
### Preprocessor Directives for Generic-Text Mappings
25
25
@@ -29,7 +29,7 @@ Because some Single Byte Character Set (SBCS) string-handling functions take (si
29
29
|`_MBCS`|Multibyte-character|`_tcsrev` maps to `_mbsrev`|
30
30
|None (the default has neither `_UNICODE` nor `_MBCS` defined)|SBCS (ASCII)|`_tcsrev` maps to `strrev`|
31
31
32
-
For example, the generic-text function `_tcsrev`, which is defined in Tchar.h, maps to `_mbsrev` if you defined `_MBCS` in your program, or to `_wcsrev` if you defined `_UNICODE`. Otherwise, `_tcsrev` maps to `strrev`. Other data type mappings are provided in Tchar.h for programming convenience, but `_TCHAR` is the most useful.
32
+
For example, the generic-text function `_tcsrev`, which is defined in tchar.h, maps to `_mbsrev` if you defined `_MBCS` in your program, or to `_wcsrev` if you defined `_UNICODE`. Otherwise, `_tcsrev` maps to `strrev`. Other data type mappings are provided in tchar.h for programming convenience, but `_TCHAR` is the most useful.
33
33
34
34
### Generic-Text Data Type Mappings
35
35
@@ -80,4 +80,4 @@ Therefore, you can write, maintain, and compile a single-source code file to run
80
80
## See Also
81
81
82
82
[Text and Strings](../text/text-and-strings-in-visual-cpp.md)<br/>
83
-
[Using TCHAR.H Data Types with _MBCS Code](../text/using-tchar-h-data-types-with-mbcs-code.md)
83
+
[Using TCHAR.H Data Types with _MBCS Code](../text/using-tchar-h-data-types-with-mbcs-code.md)
0 commit comments