How do I get the collection of code points from a String


There is a codePoints() methods in java.lang.CharSequence which returns an IntStream and I can call toArray to collect it into a list. It looks like I can get the number of code points of a kotlin.String but how do I enumerate/collect them?

I can explicitly convert it to java.lang.CharSequence but then I get a warning.


codePoints function will be available to invoke on CharSequence in Kotlin 1.1.
Until then you can use this library, which provides such function as an extension for CharSequence.