By useing #include <tchar.h>, you can support both ASCII and Unicode in your program. The tchar.h header file, defined both way to conduct two kinds of character. Use the macro “_UNICODE” to control if use Unicode.
Use TCHAR to designate a variable, and call the functions such as _tcscpy, _tcschr, _tcscmp, _tcsclen and so on, the operation would switch according to if defined “_UNICODE”.
When there is a letter “T” in the character variable, such as TCHAR, or LPCTSTR, this variety supports both ASCII and Unicode. If _UNICODE is defined, then TCHAR stands for wchar_t, or else the TCHAR stands for char.
Use the L prefix before a character or string constant to designate the wide-character-type constant.
By the way, the wchar_t is the same as unsigned short.
|
Type Name |
Bytes |
Other Names |
Range of Values |
|
Int |
4 |
signed |
–2,147,483,648 to 2,147,483,647 |
|
__int8 |
1 |
char, signed char |
–128 to 127 |
|
__int16 |
2 |
short, short int, signed short int |
–32,768 to 32,767 |
|
__int32 |
4 |
signed, signed int, int |
–2,147,483,648 to 2,147,483,647 |
|
__int64 |
8 |
long long, signed long long |
–9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
|
Bool |
1 |
none |
false or true |
|
Char |
1 |
none |
–128 to 127 |
|
Short |
2 |
short int, signed short int |
–32,768 to 32,767 |
|
Long |
4 |
long int, signed long int |
–2,147,483,648 to 2,147,483,647 |
|
long long |
8 |
none (but equivalent to __int64) |
–9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
|
Enum |
4 |
none |
Same as int |
|
Float |
4 |
none |
3.4E +/- 38 (7 digits) |
|
Double |
8 |
none |
1.7E +/- 308 (15 digits) |
|
Long double |
same as double |
none |
same as double |
|
wchar_t |
2 |
__wchar_t |
0 to 65,535 |
本文介绍如何通过包含tchar.h头文件使程序同时支持ASCII和Unicode字符集。文章详细解释了如何使用宏“_UNICODE”来控制是否使用Unicode,并说明了TCHAR类型变量如何根据不同定义支持两种字符集。此外还提供了wchar_t类型的定义及其等价类型。
2054

被折叠的 条评论
为什么被折叠?



