public static int lengthOfCodePoint ( int codePoint ) { if ( codePoint < 0 ) { throw new InvalidCodePointException ( codePoint ) ; } if ( codePoint < 0x80 ) { // normal ASCII // 0xxx_xxxx return 1 ; } if ( codePoint < 0x800 ) { return 2 ; } if ( codePoint < 0x1_0000 ) { return 3 ; } if ( codePoint < 0x11_0000 ) { return 4 ; } // Per RFC3629, UTF-8 is limited to 4 bytes, so more bytes are illegal throw new InvalidCodePointException ( codePoint ) ; }
Gets the UTF - 8 sequence length of the code point .