How many characters can you store with 1 byte?

前端 未结 4 1780
深忆病人
深忆病人 2020-12-12 19:20
1 byte = 8 bits 

So, does this mean 1 byte can only hold one character? E.g.:

\"16\" uses 2 bytes , \"9\" uses 1 byte , \"a\" uses          


        
4条回答
  •  孤街浪徒
    2020-12-12 19:39

    Yes, 1 byte does encode a character (inc spaces etc) from the ASCII set. However in data units assigned to character encoding it can and often requires in practice up to 4 bytes. This is because English is not the only character set. And even in English documents other languages and characters are often represented. The numbers of these are very many and there are very many other encoding sets, which you may have heard of e.g. BIG-5, UTF-8, UTF-32. Most computers now allow for these uses and ensure the least amount of garbled text (which usually means a missing encoding set.) 4 bytes is enough to cover these possible encodings. I byte per character does not allow for this and in use it is larger often 4 bytes per possible character for all encodings, not just ASCII. The final character may only need a byte to function or be represented on screen, but requires 4 bytes to be located in the rather vast global encoding "works".

提交回复
热议问题