This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: sizeof wchar_t
> On Linux, i686, the sizeof(wchar_t) == 4 bytes.
> 4294967295 characters can be stored in wchar_t. Wow!
>
> What is the reason for such huge size?
I think there is a number of reasons. Today, the main reason is that
'it was always that way', ie. the Linux wchar_t size is permanent part
of the ABI, now.
Given that, please note that the 16 bit Unicode is by far insufficient
to really cover everything that is used on earth (let alone things
that have been used in the past). Therefore, ISO 10646 defines a 32
bit character set, and gives funny names to the individual octets:
3 - group
2 - plane
1 - row
0 - column
In that sense, a range of 65536 characters forms a 'plane'. Unicode
happens to be plane 0, the Basic Multilingual Plane (BMP).
The Chinese are currently in the process of defining planes 3 and 4 (I
think). These will cover Chinese name characters (i.e. runes used to
give names to people and places). The Unicode Han Unification got rid
of those characters, much to the inconvenience of CJK users who can't
even make an employee database in Unicode since you cannot accurately
enter names.
ISO C++ is also planning ahead: While the \u notation gives you the
expressiveness of Unicode (i.e. \u2302 is HOUSE), the \U notation
allows for 8 hex digit.
Hope this helps,
Martin