How does Java 16 bit chars support Unicode?

后端 未结 3 1543
慢半拍i
慢半拍i 2020-12-19 03:13

Javas char is 16 bit, yet Unicode have far more characters - how does Java deal with that ?

3条回答
  •  萌比男神i
    2020-12-19 03:24

    http://en.wikipedia.org/wiki/UTF-16

    In computing, UTF-16 (16-bit UCS/Unicode Transformation Format) is a variable-length character encoding for Unicode, capable of encoding the entire Unicode repertoire. The encoding form maps each character to a sequence of 16-bit words. Characters are known as code points and the 16-bit words are known as code units. For characters in the Basic Multilingual Plane (BMP) the resulting encoding is a single 16-bit word. For characters in the other planes, the encoding will result in a pair of 16-bit words, together called a surrogate pair. All possible code points from U+0000 through U+10FFFF, except for the surrogate code points U+D800–U+DFFF (which are not characters), are uniquely mapped by UTF-16 regardless of the code point's current or future character assignment or use.

提交回复
热议问题