GTK sample (#515)
* GTK sample * Add full UTF8 recoding ability to interop
This commit is contained in:
@@ -4,18 +4,7 @@ import konan.internal.Intrinsic
|
||||
|
||||
internal fun decodeFromUtf8(bytes: ByteArray): String = kotlin.text.fromUtf8Array(bytes, 0, bytes.size)
|
||||
|
||||
fun encodeToUtf8(str: String): ByteArray {
|
||||
val result = ByteArray(str.length)
|
||||
|
||||
for (index in 0 .. str.length - 1) {
|
||||
val char = str[index]
|
||||
if (char.toInt() >= 128) {
|
||||
TODO("non-ASCII char")
|
||||
}
|
||||
result[index] = char.toByte()
|
||||
}
|
||||
return result
|
||||
}
|
||||
fun encodeToUtf8(str: String): ByteArray = kotlin.text.toUtf8Array(str, 0, str.length)
|
||||
|
||||
@Intrinsic
|
||||
external fun bitsToFloat(bits: Int): Float
|
||||
|
||||
Reference in New Issue
Block a user