THE Java™ Programming Language, Fourth Edition

(Jeff_L) #1
Returns the number of char values needed to encode the given code point.
This returns 2 for supplementary characters, otherwise 1.

public static intcodePointAt(char[] seq, int index)


Returns the code point defined at the given index in seq, taking into account
that it may be a supplementary character represented by the pair
seq[index] and seq[index+1]. There is a variant that takes an
additional limit argument that restricts the use of index+1 to be less than
a specified value.

public static intcodePointAt(CharSequence seq, int index)


Returns the code point defined at the given index in seq, taking into account
that it may be a supplementary character represented by the pair
seq.charAt(index) and seq.charAt(index+1).

public static intcodePointBefore(char[] seq, int index)


Returns the code point defined preceding the given index in seq, taking into
account that it may be a supplementary character represented by the pair
seq[index-2] and seq[index-1]. There is a variant that takes an
additional start argument, that restricts the use of index-1 and
index-2 to be greater than or equal to the specified start position.

public static intcodePointBefore(CharSequence seq, int index)


Returns the code point defined at the given index in seq, taking into account
that it may be a supplementary character represented by the pair
seq.charAt(index-2) and seq.charAt(index-1).

public static intcodePointCount(char[] seq, int start, int
count)


Returns the number of code points defined in seq[start] to
seq[start+length], taking into account surrogate pairs. Any unpaired
surrogate values count as one code point each.

public static intcodePointCount(CharSequence seq, int start,
int end)


Returns the number of code points defined in seq.charAt(start) to
seq.charAt(end), taking into account surrogate pairs. Any unpaired
surrogate values count as one code point each.

public static intoffsetByCodePoints(char[] seq, int start, int
count, int index, int numberOfCodePoints)


Returns the index into the array, that is numberOfCodePoints away from
index, considering only the subarray from seq[start] to
seq[start+length], taking into account surrogate pairs. This allows
you to skip a given number of code points, without having to manually loop
through the array, keeping track of surrogate pairs. If any unpaired surrogates
are found, they count as one code point.
Free download pdf