将字符转换为Unicode的简单方法。如。对于§,我们需要得到Unicode值"U+00A7">
这是一个将char转换为Unicode的程序。请注意char.codechar.toInt()旧格式
// Kotlin program to find Unicode value of a character
fun main(args: Array<String>) {
// Unicode table at https://unicode-table.com/en/
val char = '§'
// Unicode logic
val uni= String.format("u+%04x", char.code).uppercase()
println("The Unicode value of $char is: $uni")
}
这里是一个Github链接来尝试https://github.com/vidyesh95/UnicodeValueInKotlin