How many characters can UTF-8 encode?

前端 未结 10 1413
一个人的身影
一个人的身影 2020-11-28 01:55

If UTF-8 is 8 bits, does it not mean that there can be only maximum of 256 different characters?

The first 128 code points are the same as in ASCII. But it says UTF-

10条回答
  •  鱼传尺愫
    2020-11-28 02:22

    UTF-8 does not use one byte all the time, it's 1 to 4 bytes.

    The first 128 characters (US-ASCII) need one byte.

    The next 1,920 characters need two bytes to encode. This covers the remainder of almost all Latin alphabets, and also Greek, Cyrillic, Coptic, Armenian, Hebrew, Arabic, Syriac and Tāna alphabets, as well as Combining Diacritical Marks.

    Three bytes are needed for characters in the rest of the Basic Multilingual Plane, which contains virtually all characters in common use[12] including most Chinese, Japanese and Korean [CJK] characters.

    Four bytes are needed for characters in the other planes of Unicode, which include less common CJK characters, various historic scripts, mathematical symbols, and emoji (pictographic symbols).

    source: Wikipedia

提交回复
热议问题