5

I am getting some Unicode string(emoji icons) from server in json string format.

My problem is strange and I am trying for last two days to resolve this issue. When I parse json and store all the Unicode string in an ArrayList<String> and try to set the text on TextView by getting value from the same ArrayList then it shows Unicode characters as :

Ghcghchgc\ud83d\ude03\ud83d\ude03fyju\ud83d\ude0c6\u20e3

and when the same string I set on textview by passing static value as : textview.settext("Ghcghchgc\ud83d\ude03\ud83d\ude03fyju\ud83d\ude0c6\u20e3")

then the textview is showing perfect emojis.

I am stuck at this point. Can anybody please help me to resolve this issue or tell me if I am doing something wrong.

Krupa Patel
  • 3,309
  • 3
  • 23
  • 28
rahul
  • 2,613
  • 8
  • 32
  • 55

2 Answers2

6

This sounds like you want to unescape your string that you've got from JSON. If you don't mind adding a library, Apache Commons has a String.unescapeJava function which does what you need. If you don't want to add that library, see this answer.

Community
  • 1
  • 1
DarkDust
  • 90,870
  • 19
  • 190
  • 224
  • i also use this but when i get respone again from server enojis become `?` symbol. – Hasmukh Kachhatiya Sep 28 '17 at 10:05
  • @Hasmukhkachhatiya That means that your system does not have the proper Glyph for the symbol (i.e. the code point is not known) [read the description](https://en.wikipedia.org/wiki/Substitute_character) – Bonatti Sep 13 '18 at 13:51
0

This is what has worked for me ( Kotlin version ):

textView.text = String(Character.toChars(0x1F389))

Biscuit
  • 4,840
  • 4
  • 26
  • 54
Antroid
  • 391
  • 4
  • 15