The basic way to support both ASCII and Unicode:
2008-07-06 17:12
411 查看
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.
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 |
相关文章推荐
- Unable to update the EntitySet 'T_JsAPI' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.
- tomcat报"The servlets named [x] and [y] are both mapped to the url-pattern[z] which is not permitted"
- 【摘要】Advanced Serialization: Format Your Way to Success with the .NET Framework Versions 1.1 and 2.0
- The servlets named [x] and [y] are both mapped to the url-pattern [/JServlet] which is not permitted
- C++0x : Inefficient way to perform trivial named args and default args at the same time
- Some things about the ASCII,Unicode and UTF-8
- it has a DefiningQuery and no InsertFunction element exists in the ModificationFunctionMapping element to support the current op
- The servlets named [LoginCheckServlet] and [LoginCheckServlet] are both mapped to the url-pattern [/
- 翻译 Scribe : a way to aggregate data and why not, to directly fill the HDFS?
- Unable to update the EntitySet 'XXX' because it has a DefiningQuery and no element exists in the element to support the current operation.
- Model-View-Presenter: Why We Need It And The Basic Pattern (Introduction To CAB/SCSF Part 23)
- How to support both ipv4 and ipv6 address for JAVA code.
- How to Support MUI (Multi User Interface) for both Vista and XP
- VC编译错误:The source files "*\A.cpp " and "*\A.cpp " are both configured to produce the output file "*\
- unicode control and basic latin - ASCII
- 错误:Found both android-support-v4 and android-support-v13 in the dependency list.
- The servlets named [X] and [Y] are both mapped to the url-pattern [/Z] which is not permitted
- WampDeveloper Pro is the best (and fastest) way to create and run multiple websites on Windows, usin
- A way to control the width of columns and bars (RDL)
- The different way to start a service(Bind_auto_create will just create a service and the service will exit when unbind)