我被代码点代码单元搞晕了一个代码单元永远只有16位,一个代码点可能是16位也可能是32位?
char charAt(int index)  返回short
int codePointAt(int index) 返回大于short的int
是不是可以结论codePointCount永远不大于length?
String中可以含有超过16位表示的字符,一个char可以吗,char的长度是固定16bit还是可变为32bit?

解决方案 »

  1.   

    java内部都是unicode,是16位的。你先这么理解吧。
      

  2.   

    有一些字符是32位的,不过这些是 java 专用的 unicode 编码格式
      

  3.   

    java不是使用的unicode字符集吗?不用关心是多少位的.
      

  4.   

    In the Java SE API documentation, Unicode code point is used for character values in the range between U+0000 and U+10FFFF, and Unicode code unit is used for 16-bit char values that are code units of the UTF-16 encoding.对着段话不解,代码点仅仅是指[U+0000 to U+10FFFF]之间的代码单元吗,如果一个String不含这个区间的char就意味着codePointCount=0?
      

  5.   

    the first from the high-surrogates range, (\uD800-\uDBFF), the second from the low-surrogates range (\uDC00-\uDFFF). 意思是high+low<=U+10FFFF?不会有大于U+10FFFF的letter存在?