In Kotlin Native how would I find the number of by...
# kotlin-native
s
In Kotlin Native how would I find the number of bytes in a utf-8 string?
Copy code
@Test
    fun `The number of bytes in a euro is three`(){
        //count and length return 1 but a euro symbol is a multibyte character
        assertEquals(3, "€".count, "Wrong number of bytes for a Euro.") 
    }
s
If you have access to kotlinx.serialization, you can use its
String.toUtf8Bytes()
extension function and call
size
on the result.
m
s
Thanks, the second suggestion looks like what I need.