Hi, I have a `wchar_t *` in C that I try to conver...
# kotlin-native
z
Hi, I have a
wchar_t *
in C that I try to convert to a kotlin string with kotlin native. I've used
.toKStringFromUtf32()
which works well but it seems that the string has a trailing null byte which is not so pretty 🙂 Is that expected behavior? The documentation states
Returns: the [kotlin.String] decoded from given zero-terminated UTF-32-encoded C string.
so my interpretation would be that this is a bug?
d
Are you saying the returned
kotlin.String
has a
\0
in it?
z
So the symptoms were that intellij displays an empty square after each string (which I think I've inspected with the debugger some time ago). I've imported the toKStringFromUtf32 function into my project and swapped the two lines you suggested and the extra characters are gone and the output looks like expected now 🙂
Unfortunately I couldn't make the debugger give me definitive proof that there's a null byte at the end today but as swapping these lines fixes it it's pretty safe to say that was the problem 😉
d
Yeah. I'll make a PR.
👍 1
z
👍 please tag me (@z3ntu) so I get notifications 🙂
I'll go offline now, thanks for your help!
d
No problem