4 ms·
The maximum number of characters in Unicode is 1111998 (this excludes non-characters and surrogates). UTF-16 can encode 1112064 code points (this includes non-
by klodolph 10y ago
The maximum number of characters in Unicode is 1111998 (this excludes non-characters and surrogates). UTF-16 can encode 1112064 code points (this includes non-characters). This is quite a bit smaller than the 21 bits quoted: you really get the 16-bit BMP plus the 20-bit astral planes, minus the surrogates (2048 of them). The "non-characters" number 66.
- TazeTSchnitzel 10y agoThank you for that correction, I suspected 2^21 might not be quite correct.
- vorg 10y ago> The maximum number of characters ... (this excludes non-characters and surrogates) You should exclude the surrogates but include the non-characters when tallying the characters. According to Unicode's 2013 Corridendum 9, "Noncharacters in the Unicode Standard are intended for internal use and have no standard interpretation when exchanged outside the context of internal use. However, they are not illegal in interchange nor do they cause ill-formed Unicode text". See http://www.unicode.org/versions/corrigendum9.html http://www.unicode.org/versions/corrigendum9.html
- klodolph 10y agoI can see why this might be confusing—I chose the word "character" carefully. The annex you cited clarifies that noncharacters are code points that can be used in interchange. However, this does not mean that a noncharacter is a character. The number of code points available for use as characters must, by definition, exclude the noncharacters. So, to expand on the original comment, Unicode defines 1114112 code points, of which 1112064 can be used in interchange, and 1111998 can be defined as characters. UTF-16 can only represent the 1112064 that are valid for interchange, and the 66 noncharacters should generally be avoided (especially U+FFFE).