The basic way to support both ASCII and Unicode:

本文介绍如何通过包含tchar.h头文件使程序同时支持ASCII和Unicode字符集。文章详细解释了如何使用宏“_UNICODE”来控制是否使用Unicode,并说明了TCHAR类型变量如何根据不同定义支持两种字符集。此外还提供了wchar_t类型的定义及其等价类型。

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

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值