https://kotlinlang.org logo
#compose
Title
# compose
k

Kshitij Patil

03/29/2022, 10:32 AM
How do we show Emojis in Jetpack Compose? I came across this open issue. Any updates on the same?
p

Paul Woitaschek

03/29/2022, 10:48 AM
We created an EmojiPainter for that
k

Kshitij Patil

03/29/2022, 10:50 AM
@Paul Woitaschek thanks for the reply! Could you share the code? Have you tried using
androidx.emoji
?
p

Paul Woitaschek

03/29/2022, 11:27 AM
Well we only use it to draw the emojis, not emojis in text
a

Albert Chang

03/29/2022, 12:11 PM
This has nothing to do with EmojiCompat. Java uses UTF-16 and
\uD83D\uDE02
is the UTF-16 representation of
U+1F602
. For more details see https://en.wikipedia.org/wiki/UTF-16#Code_points_from_U+010000_to_U+10FFFF.
🤯 2
k

Kshitij Patil

03/29/2022, 12:22 PM
Okay @Albert Chang 😮, so we will be maintaining these strings for custom Emoji Panel. Should we maintain the strings in UTF-8 or UTF-16 format, considering better support? If UTF-16, how to convert a UTF-8 string to UTF-16
a

Albert Chang

03/29/2022, 12:32 PM
If you want to use code points, you have to their UTF-16 representations. However you can directly use emojis as literals (e.g.
const val emoji = "😂"
).
p

Paul Woitaschek

03/29/2022, 1:44 PM
Yeah but they will only work if they are supported by the system font
https://developer.android.com/jetpack/androidx/releases/emoji2 This has no integration with compose at all I guess?
k

Kshitij Patil

03/29/2022, 1:47 PM
Yup
p

Paul Woitaschek

03/29/2022, 1:50 PM
And compose takes no spannable. So the only way is an androidView here
k

Kshitij Patil

03/29/2022, 1:53 PM
Which I don't think is a good idea in terms of performance.
302 Views