toChars

fun toChars(codePoint: Int, dst: CharArray, dstIndex: Int): Int

Converts the specified character (Unicode code point) to its UTF-16 representation. If the specified code point is a BMP (Basic Multilingual Plane or Plane 0) value, the same value is stored in dst[dstIndex], and 1 is returned. If the specified code point is a supplementary character, its surrogate values are stored in dst[dstIndex] (high-surrogate) and dst[dstIndex+1] (low-surrogate), and 2 is returned.

Return

1 if the code point is a BMP code point, 2 if the code point is a supplementary code point.

Since

1.5

Parameters

codePoint

the character (Unicode code point) to be converted.

dst

an array of char in which the codePoint's UTF-16 value is stored.

dstIndex

the start index into the dst array where the converted value is stored.

Throws

if the specified codePoint is not a valid Unicode code point.

if the specified dst is null.

if dstIndex is negative or not less than dst.length, or if dst at dstIndex doesn't have enough array element(s) to store the resulting char value(s). (If dstIndex is equal to dst.length-1 and the specified codePoint is a supplementary character, the high-surrogate value is not stored in dst[dstIndex].)