0

I wanted to show Unicode in a text view in my android app. I searched for a solution but nothing really helped. I wanted to do this programmatically in Kotlin as I want to concatenate it with the data that I fetch from Firestore.

Codist
  • 737
  • 8
  • 23

2 Answers2

2

You can parse unicode from html to string by using HTML library like

val bullet = "&#8226"
print("this is bullet a ${Html.fromHtml(bullet)}")
Anshul
  • 1,495
  • 9
  • 17
  • I wanted to use a big bullet which I got from https://stackoverflow.com/a/36743430/13935956 it might be helpful if anybody is looking for it. – Codist Aug 24 '21 at 15:24
  • 1
    `Html.fromHtml(bullet)` is deprecated since Android N. Use `Html.fromHtml(bullet,Html.FROM_HTML_MODE_LEGACY)` instead. See [StackOverflow](https://stackoverflow.com/questions/37904739/html-fromhtml-deprecated-in-android-n) – Andreas Busslinger Feb 08 '22 at 17:10
2

First of all, check that font you use supports Unicode. Then you can use Html.fromHtml as @Anshul advised but keep in mind that it is deprecated and you need to use Html.FROM_HTML_MODE_LEGACY as it was advised in Unicode characters not displayed in TextView.setText

Vlad L.
  • 154
  • 1
  • 9