Reputation: 111
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?
Upvotes: 2
Views: 5704
Reputation: 111
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.
Upvotes: 2
Reputation: 11457
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:-
Upvotes: 1
Reputation: 1111
This is html encoding string. Check code:
String txt = "\u00F0\u009F\u0098\u0098";
tvHihiView.setText(Html.fromHtml(txt));
Upvotes: 0
Reputation: 11
TextView txt_price = (TextView) findViewById(R.id.txt_price);
txt_price.setText("\u20B9" + " 5000");
Upvotes: -1
Reputation: 812
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.
Upvotes: 0
Reputation: 4064
You need to unescape
your escaped String.
You can use StringEscapeUtils.unescapeJava(String) to unescape it.
The problem is fully explained here.
Upvotes: 0