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
Except for a small, ISO 2022 japanese minority, wchar_t is always going to be unicode. If you are really anxious you can make sure of that at compile time:
#ifndef __STDC_ISO_10646__
#error "non-unicode wchar_t, unsupported system"
#endif
Sometimes wchar_t is 16bits UCS-2 sometimes 32bits UCS-4, so what? Just use sizeof(wchar_t)
. wchar_t is NOT meant to be sent to disk nor to the network, it is only meant to be used in memory.
See also Should UTF-16 be considered harmful? on this site.