toCharArray
Converts this code point to a CharArray.
For basic (BMP) code points, returns an array with a single Char with the same
codevalue.For supplementary code points, returns an array with two Char values representing the surrogate pair encoding this codepoint..
Since Kotlin
2.5Return
A CharArray containing one or two Char values depending on whether this is a basic or supplementary code point.
See also
Samples
import kotlin.text.unicode.*
import kotlin.test.*
fun main() {
//sampleStart
val basicCodePoint = 'K'.toCodePoint()
println(basicCodePoint.toCharArray().joinToString { it.code.toHexString() }) // 0000004b
val supplementaryCodePoint = CodePoint(0x1F60B) // 😋
println(supplementaryCodePoint.toCharArray().joinToString { it.code.toHexString() }) // 0000d83d, 0000de0b
//sampleEnd
}Content copied to clipboard