I try to use `kotlin-stdlib/kotlin.text/toByteArra...
# kotlin-native
n
I try to use
kotlin-stdlib/kotlin.text/toByteArray
in my multiplatform project with no luck. What’s the idea behind converting strings to bytes and vice versa? Should I write platform-specific code at this point?
Okay, I see that
kotlin-stdlib/kotlin.native/toUtf8
is available on String. But I cannot invoke it. What am I doing wrong?
l
there is
String.toByteArray
in
kotlinx.io.core
you would need to add the proper dependency in common source set:
implementation "org.jetbrains.kotlinx:kotlinx-io:0.1.0-alpha-17-rc13"
and the respective native counterparts jvm:
implementation "org.jetbrains.kotlinx:kotlinx-io-jvm:0.1.0-alpha-17-rc13"
and in native:
implementation "org.jetbrains.kotlinx:kotlinx-io-native:0.1.0-alpha-17-rc13"
n
Thank you Leonid. I try to not add any external dependencies. For now I just have written two platform specific versions. Works perfectly well.
l
understandable, but since those are
org.jetbrains.kotlinx
I don’t see them as “external” 🙂