2

enter image description here

str = videoname.get(i);
    String toServer = str;
    String toServerUnicodeEncoded = StringEscapeUtils.escapeJava(toServer);
    viewHolder.textss.setText(toServerUnicodeEncoded);
    Log.e("emos",toServerUnicodeEncoded);

I am retrieving a string from URL using volley and the string contains emojis in it which I want to display in Android TextView. So for that, I have taken the string then passed it in StringEscapeUtils.escapeJava(toServer) and after that I am getting the emoji in "\u00F0\u009F\u0098\u0098" form, Instead of "\uD83D\uDE18" form . So how to display emoji in textview?

Zoe
  • 27,060
  • 21
  • 118
  • 148
Pooja Pachchigar
  • 111
  • 2
  • 12

6 Answers6

2
String title = new String(c.getString("title").getBytes("ISO-8859-1"), "UTF-8");

While Parsing the response I used this now instead of:

String title = String(c.getString("title");

This solved my emoji issue.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Pooja Pachchigar
  • 111
  • 2
  • 12
1

This worked for me , Try this.

Import this library

implementation 'org.apache.commons:commons-lang3:3.4'

Then use its method to convert String(emoji code) to Emoji to show in TextView

textView.setText(StringEscapeUtils.unescapeJava(string_value));

Eg:-

Input String :- "\ud83d\ude01"

Result:-

enter image description here

Quick learner
  • 10,632
  • 4
  • 45
  • 55
0

You need to unescape your escaped String.

You can use StringEscapeUtils.unescapeJava(String) to unescape it.

The problem is fully explained here.

Adib Faramarzi
  • 3,798
  • 3
  • 29
  • 44
0

You don't need to convert it to unicode directly use that string code like

 TextView txt = (TextView) findViewById(R.id.txt);
        txt.setText("\u00F0");

for more unicide code check this URL

Hope this helpful to you.

Adil
  • 812
  • 1
  • 9
  • 29
0

This is html encoding string. Check code:

String txt = "\u00F0\u009F\u0098\u0098";
tvHihiView.setText(Html.fromHtml(txt));
Brian Hoang
  • 1,111
  • 9
  • 18
-1

TextView txt_price = (TextView) findViewById(R.id.txt_price);

txt_price.setText("\u20B9" + " 5000");