Are `char16_t` and `char32_t` misnomers?

前端 未结 3 1671
慢半拍i
慢半拍i 2021-02-07 20:50

NB: I\'m sure someone will call this subjective, but I reckon it\'s fairly tangible.

C++11 gives us new basic_string types

3条回答
  •  长发绾君心
    2021-02-07 20:58

    are these names fundamentally flawed?

    (I think most of this question has been answered in the comments, but to make an answer) No, not at all. char16_t and char32_t were created for a specific purpose. To have data type support for all Unicode encoding formats (UTF-8 is covered by char) while keeping them as generic as possible to not limit them to only Unicode. Whether they are unsigned or have a fixed-width is not directly related to what they are: character data types. Types which hold and represent characters. Signedness is a property of data types that represent numbers not characters. The types are meant to store characters, either a 16 bit or 32 bit based character data, nothing more or less.

提交回复
热议问题