toSingleChar

Converts this basic (BMP) code point to a single Char.

This method is only applicable to basic code points in the range 0x0000 to 0xFFFF. For supplementary code points, use toSurrogatePair or toCharArray instead.

Since Kotlin

2.5

Return

The Char representation of this basic code point.

See also

Throws

if this is a supplementary code point.

Samples

import kotlin.text.unicode.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val basicCodePoint = 'Ü'.toCodePoint()
val char = basicCodePoint.toSingleChar()

println(char) // Ü

val supplementaryCodePoint = CodePoint(0x1F60B) // 😋
// supplementaryCodePoint.toSingleChar() // will fail with IllegalArgumentException 
   //sampleEnd
}