WCHAR and wchar_t 的区别 (zz)
2012-06-28 16:27
323 查看
//z 2012-6-28 16:31:32 PM is2120@csdn
在定义了unicode的情况下,wsprintf的格式字符串
Q:I was wondering if there was any practical difference between WCHAR and wchar_t.
A:
Well, one practical difference would be that
is just a
wchar_t is a distinct type, defined by the C++ standard.
WCHAR is nonstandard, and as far as I know, exists only on Windows. However, it is simply a typedef (or possibly a macro) for wchar_t, so it makes no practical difference.
Older versions of MSVC did not have wchar_t as a first-class type, instead of was simply a typedef for
Most likely, they introduced WCHAR to represent "wide character type" across any compiler version, whether or not wchar_t exists as a native type.
You should use wchar_t in your code though. That's what it's for.
//z 2012-6-28 16:31:32 PM is2120@csdn
//z 2012-12-03 10:36:01 IS2120@BG57IV3.T3905646052.K[T42,L399,R15,V371]
_T _TEXT L
有什么区别
_T("Text") is a narrow-character (ASCII) literal in an ANSI build but a wide character (UNICODE) literal in a Unicode build.
L"Text" is always a wide-character literal, regardless of preprocessor definitions.
_T() is a macro, the L prefix is part of the core C and C++ language lexical structure.
在定义了unicode的情况下,wsprintf的格式字符串
c | A single character. This sequence is interpreted as type WCHAR. |
C | A single character. This sequence is interpreted as type CHAR. |
A:
Well, one practical difference would be that
WCHARdoesn't exist on my platform. For Windows only (and with no intention of ever porting the program to another platform) and with the necessary headers included, it's the same (since
WCHAR
is just a
typedef).
wchar_t is a distinct type, defined by the C++ standard.
WCHAR is nonstandard, and as far as I know, exists only on Windows. However, it is simply a typedef (or possibly a macro) for wchar_t, so it makes no practical difference.
Older versions of MSVC did not have wchar_t as a first-class type, instead of was simply a typedef for
short
Most likely, they introduced WCHAR to represent "wide character type" across any compiler version, whether or not wchar_t exists as a native type.
You should use wchar_t in your code though. That's what it's for.
//z 2012-6-28 16:31:32 PM is2120@csdn
//z 2012-12-03 10:36:01 IS2120@BG57IV3.T3905646052.K[T42,L399,R15,V371]
_T _TEXT L
有什么区别
_T("Text") is a narrow-character (ASCII) literal in an ANSI build but a wide character (UNICODE) literal in a Unicode build.
L"Text" is always a wide-character literal, regardless of preprocessor definitions.
_T() is a macro, the L prefix is part of the core C and C++ language lexical structure.
相关文章推荐
- Linux and Windows snprintf区别(zz)
- char,wchar_t,TCHAR 三者的区别与联系(ZZ)
- MYSQL 表连接 ON AND 和ON WHERE 的区别
- struts2 FilterDispatcher 和 StrutsPrepareAndExecuteFilter 的区别
- Difference between shallow copy and deep copy? 浅复制和深复制的区别
- NorFlash、NandFlash、eMMC比较区别
- [ZZ]C++中,引用和指针的区别
- JDK,JRE,JVM区别与联系(ZZ)
- [ZZ] Deferred Rendering and HDR
- CSS “点 ”“井号”的含义and ID class区别
- AtomicInteger 中 incrementAndGet与getAndIncrement 两个方法的区别
- 【综合转贴】CSS “点 ”“井号”的含义and ID class区别?
- 同步电机与异步电机的区别(zz)
- DBA_OBJECTS中object_id and data_object_id 区别
- Delphi中destroy, free, freeAndNil, release用法和区别
- map and flatmap 区别
- Intent setType、setData和setDataAndType的区别
- char,TCHAR,WCHAR区别
- [zz] Read and write a properties file
- 堆和栈的区别【zz】