Scott Peterson
06/07/2022, 3:47 PMUInt8
encoded byte array that I need to convert to a UTF-8 string, using Kotlin.
various things I’ve tried have converted it into the ASCII value “d”, which is the correct value. But I want the UTF-8 string value “100"UInt8
byte array to string: it.decodeToString()
string to char: string.first()
(I know it’s a single value which is why I can call first() )
char to decimal: char.code
val test = it[0].toInt()
Joffrey
06/07/2022, 4:14 PMScott Peterson
06/07/2022, 4:17 PMephemient
06/07/2022, 4:25 PMChar
is a UTF-16 code unit for historical reasons)Scott Peterson
06/07/2022, 4:28 PMephemient
06/07/2022, 4:33 PMString.codePointAt(0)
you'll have to decide whether that's actually what you want or if you want to deal with normalization forms, combining sequences, emoji modifier sequences, flags, etc.