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
As I read the relevant standards, it seems like Microsoft fcked this one up badly.
My manpage for the POSIX
says that:
- wchar_t: Integer type whose range of values can represent distinct wide-character codes for all mem‐ bers of the largest character set specified among the locales supported by the compilation environment: the null character has the code value 0 and each member of the portable character set has a code value equal to its value when used as the lone character in an integer character constant.
So, 16 bits wchar_t is not enough if your platform supports Unicode. Each wchar_t is supposed to be a distinct value for a character. Therefore, wchar_t goes from being a useful way to work at the character level of texts (after a decoding from the locale multibyte, of course), to being completely useless on Windows platforms.