Does the C++ standard mandate an encoding for wchar_t?

后端 未结 7 2141
礼貌的吻别
礼貌的吻别 2021-02-10 07:09

Here are some excerpts from my copy of the 2014 draft standard N4140

22.5 Standard code conversion facets [locale.stdcvt]

3 F

7条回答
  •  感动是毒
    2021-02-10 08:02

    No.

    wchar is only required to hold the biggest locale supported by the compiler. Which could theoretically fit in a char.

    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 (22.3.1).

    — C++ [basic.fundamental] 3.9.1/5

    as such it's not even required to support Unicode

    The width of wchar_t is compiler-specific and can be as small as 8 bits. Consequently, programs that need to be portable across any C or C++ compiler should not use wchar_t for storing Unicode text. The wchar_t type is intended for storing compiler-defined wide characters, which may be Unicode characters in some compilers.

    ISO/IEC 10646:2003 Unicode standard 4.0

提交回复
热议问题