In the earlier versions of JDK, the
Character size was only two bytes or 16-bit , which means it could support only characters with codes ranging from 0 to FFFF . But as more languages are supported, the number of characters increased to 10FFFF , so it needed to support 32-bit Unicode characters.
Lets understand the following terms first.
16-bit characters to 32-bit characters caused a problem to Java since supplemental characters can not be stored in regular character whose size is 16-bit . To avoid this Java uses two chars to represent a single supplemental character. The first char is called the high surrogate where as the second character is called the low surrogate.
To primarily help with this problem a new method called codePointAt() is provided. This method returns int instead of char . Since int is 32-bits , it can store these two chars with out any problem. Java also provided overloaded forms that operate on int. Some sample methods are:
static boolean isDigit(int codePoint) Listed below are more methods which help in handling 32-bit Unicode Code Points.
|