Why can CHAR_BIT usually be 8 in c++

  • A+
Category:Languages

According to N4140(C++11 working draft):

The fundamental storage unit in the C ++ memory model is the byte. A byte is at least large enough to contain any member of the basic execution character set and the eight-bit code units of the Unicode UTF-8 encoding form and is composed of a contiguous sequence of bits, the number of which is implementation-defined. (§6.6.1-1; p.48)

I think 8 bits are needed only to contain all members of "the eight-bit code units of the Unicode UTF-8 encoding form". Aren't more bits needed also to contain all members of "the basic execution character set"? Why can CHAR_BIT be 8 in many implementations?


The basic execution set contains 96 characters, not one of which is outside of the ASCII character set. And UTF-8's first 127 characters are ASCII.

So no, there is no need for char to be bigger than 8 bits, on the basis of the basic execution set characters.

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: