Michal Klimczak
07/27/2021, 3:13 PMtwenti̩
as example. This i̩
with a little dash at the bottom is treated by kotlin as two separate chars, but swift treats it as one. So when I defined formatting which spans across the whole word in shared code with text.length
, it calculates it as 7 chars. When I use it in Swift, which thinks of it as 6 chars (via *let* characters = Array(text)
), I get Fatal error: Index out of range
. Any ideas how to work with these?russhwolf
07/27/2021, 4:28 PMtext.codePointAt(index)
and text.codePointCount()
, but note they're JVM-onlyMichal Klimczak
07/27/2021, 4:37 PMprintln("twenti̩: ${text.codePointCount(0, text.length)} | ${text.length}")
//twenti̩: 7 | 7
interface TextLengthProvider {
fun length(text: String) : Int
}
and implement it on both platforms (i.e. delegate completely to the swift impl). Could not have used expect/actual, because we're dealing with pure swift here.