Is there an equivalent of `java.lang.Character.isL...
# stdlib
m
Is there an equivalent of
java.lang.Character.isLetter(int codePoint)
in Kotlin? I'm getting a warning when importing
j.l.Character
but I don't think there are functions operating on code points.
1
m
FWIW, there is https://github.com/cketti/kotlin-codepoints but it doesn't seem to contain
isLetter
r
You can do
codePoint.toChar().isLetter()
💡 1
m
Ah, that works. Thanks!
k
That's not going to work for codepoints outside the BMP. The doc says "The resulting
Char
code is represented by the least significant 16 bits of this
Int
value."
It seems that a good solution might be to define a value class called
CodePoint
and create member functions for it that mirror the
Char.isXxxx
functions. And looking at the doc for `isSupplementaryCodePoint`, it says "In the future it could be deprecated in favour of an overload that would accept a
CodePoint
type." This suggests that someone at JetBrains is already thinking of exactly this.