3 ms·
> The maximum number of characters ... (this excludes non-characters and surrogates) You should exclude the surrogates but include the non-characters when tall
by 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).