fromSurrogatePair
Creates a CodePoint from a UTF-16 surrogate pair.
The high character must be a high surrogate and the low character must be a low surrogate. The returned code point is always in the supplementary range 0x10000 to 0x10FFFF.
Since Kotlin
2.5Return
A CodePoint decoded from the surrogate pair.
Parameters
high
The high surrogate component.
low
The low surrogate component.
See also
Throws
Samples
import kotlin.text.unicode.*
import kotlin.test.*
fun main() {
//sampleStart
val high = '\uD83D'
val low = '\uDE0B'
val codePoint = CodePoint.fromSurrogatePair(high, low)
println(codePoint) // 😋
// conversion from surrogate pair always result in supplementary code points
println(codePoint.size) // 2
println("codePoint.isSupplementary is ${codePoint.isSupplementary}") // true
// CodePoint.fromSurrogatePair('a', low) // will fail with IllegalArgumentException
//sampleEnd
}Content copied to clipboard