code

Platform and version requirements: JVM (1.5), JS (1.5), Native (1.5)
inline val Char.code: Int

Returns the code of this Char.

Code of a Char is the value it was constructed with, and the UTF-16 code unit corresponding to this Char.

import java.util.*
import kotlin.test.*

fun main(args: Array<String>) {
//sampleStart
val string = "0Azβ"
println(string.map { it.code }) // [48, 65, 122, 946]
//sampleEnd
}

© 2010–2021 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/code.html