From 7e9f8b5c8cb3fd8967367d20bd078776ce70b5b2 Mon Sep 17 00:00:00 2001 From: Dominic Fischer Date: Wed, 4 Mar 2020 11:18:04 +0000 Subject: [PATCH] Fix toKStringFromUtf32 (#3903) Remove null terminator from returned String --- Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Utils.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Utils.kt b/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Utils.kt index 72dda83a49b..3062fd3fd68 100644 --- a/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Utils.kt +++ b/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Utils.kt @@ -532,8 +532,8 @@ public fun CPointer.toKStringFromUtf32(): String { var toIndex = 0 while (true) { val value = nativeBytes[fromIndex++] - toIndex++ if (value == 0) break + toIndex++ if (value >= 0x10000 && value <= 0x10ffff) { toIndex++ }