The standard wide character type
In C, wchar_t
is a typedef
-name for an integral type
large enough to hold the widest character set
In C++, std::wchar_t
is a builtin type
large enough to hold the widest character set the compiler supports.
The languages' respective standard
s place no other requirement this type. They may be exactly the same size as char
, and, if the compiler chooses not to distinguish multibyte characters from traditional ASCII characters, may have the exact same set of values! In addition, the standards allow wchar_t
to be wider
than anything needed for the character set.
For most 32-bit
C and C++ compilers, such as x86 gcc
is implemented as a 16-bit
type, closely resembling an unsigned short
, enough to encode the Unicode
) character set.