According to cppreference.com's doc on wchar_t
:
wchar_t
- type for wide character representation (see wide strings). Required to be large enough to represent any supported character code point (32 bits on systems that support Unicode. A notable exception is Windows, where wchar_t is 16 bits and holds UTF-16 code units) It has the same size, signedness, and alignment as one of the integer types, but is a distinct type.
The Standard says in [basic.fundamental]/5
:
Type
wchar_-t
is a distinct type whose values can represent distinct codes for all members of the largest extended character set specified among the supported locales. Typewchar_-t
shall have the same size, signedness, and alignment requirements as one of the other integral types, called its underlying type. Typeschar16_-t
andchar32_-t
denote distinct types with the same size, signedness, and alignment asuint_-least16_-t
anduint_-least32_-t
, respectively, in<cstdint>
, called the underlying types.
So, if I want to deal with unicode characters, should I use wchar_t
?
Equivalently, how do I know if a specific unicode character is "supported" by wchar_t
?