public void encodeString ( final String s ) throws IOException { final int lenChars = s . length ( ) ; final int lenCharacters = s . codePointCount ( 0 , lenChars ) ; encodeUnsignedInteger ( lenCharacters ) ; encodeStringOnly ( s ) ; }
Encode a string as a length - prefixed sequence of UCS codepoints each of which is encoded as an integer . Look for codepoints of more than 16 bits that are represented as UTF - 16 surrogate pairs in Java .