Why is wchar_t
needed? How is it superior to short
(or __int16
or whatever)?
(If it matters: I live in Windows world. I don\'t
wchar_t
is the primitive for storing and processing the platform's unicode characters. Its size is not always 16 bit. On unix systems wchar_t
is 32 bit (maybe unix users are more likely to use the klingon charaters that the extra bits are used for :-).
This can pose problems for porting projects especially if you interchange wchar_t
and short, or if you interchange wchar_t
and xerces' XMLCh
.
Therefore having wchar_t
as a different type to short is very important for writing cross-platform code. Cleaning up this was one of the hardest parts of porting our application to unix and then from VC6 to VC2005.