https://kotlinlang.org logo
#android
Title
# android
a

Attila Blenesi

06/16/2020, 12:06 PM
Hello, 👋 Is there a way to identify extended grapheme clusters? 👩‍👩‍👧‍👧 👍🏽 <- My use case is detecting first user perceived character in a String
r

Ryan

06/16/2020, 12:08 PM
can you elaborate some more
1
a

Attila Blenesi

06/16/2020, 12:28 PM
String[0] in the cases I posted return the first section of the unicode character that the emote is composed of :
Copy code
val text = "👩‍👩‍👧‍👧 user perceived characters 👍🏽"
print(text[0])

?
👩‍👩‍👧‍👧 =
\u200D\uD83D\uDC69\u200D\uD83D\uDC67\u200D\uD83D\uDC66
Android Studio does not support Zero Width Joiner characters so it look like this in the IDE:
r

Ryan

06/16/2020, 12:28 PM
unicode takes up more than one position in a string
1
a

Attila Blenesi

06/16/2020, 12:35 PM
Yeah, I'm asking because I did not see any clear way to achieve this in Kotlin / Java / Android (the question posted is web specific.)
I happy to create a Stack Overflow question myself.
This was
Added in API level 24
So would still need something backwards compatible
g

Gonçalo Palaio

06/16/2020, 6:26 PM
Nothing is simple when dealing with emoji and I’m probably missing the point but couldn’t you loop through the codepoints and find the zero width joiners?
a

Attila Blenesi

06/20/2020, 11:56 AM
You are right to some extent, there are some cases where zero width joiners are not present.
8 Views