Is ASCII code 7-bit or 8-bit?

前端 未结 6 1312
情深已故
情深已故 2020-12-02 05:49

My teacher told me ASCII is 8-bit character coding scheme. But it is defined only for 0-127 codes which means it can be fit into 7-bits. So can\'t it be argued that ASCII bi

6条回答
  •  长情又很酷
    2020-12-02 05:58

    ASCII encoding is 7-bit, but in practice, characters encoded in ASCII are not stored in groups of 7 bits. Instead, one ASCII is stored in a byte, with the MSB usually set to 0 (yes, it's wasted in ASCII).

    You can verify this by inputting a string in the ASCII character set in a text editor, setting the encoding to ASCII, and viewing the binary/hex:

    Aside: the use of (strictly) ASCII encoding is now uncommon, in favor of UTF-8 (which does not waste the MSB mentioned above - in fact, an MSB of 1 indicates the code point is encoded with more than 1 byte).

提交回复
热议问题