Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decode the unicode char in Java string?

In my android project, i need to display a text with a TextView, but i got a very suck issues with the following string. Someone help me, please.

Here is my java string :

TRAI floats new paper on \\u0027Net Neutrality\\u0027: Lists disadvantages of zero-rating plans

It's display like this in my TextView:

TRAI floats new paper on \u0027Net Neutrality\u0027: Lists disadvantages of zero-rating plans

I want it to show like this:

TRAI floats new paper on 'Net Neutrality': Lists disadvantages of zero-rating plans"

What should i do ? Thanks in advance!

Update :

I have already tried with this code, but don't work for me.

title.setText(Html.fromHtml(news.getTitle()).toString())

And i want a solution for all '\uxxxx' like chars, not the '\u0027' only.

like image 922
tomisyourname Avatar asked Jun 17 '26 23:06

tomisyourname


2 Answers

Don't double the backslahes:

String s = "TRAI floats new paper on \u0027Net Neutrality\u0027: Lists disadvantages of zero-rating plans";

This will have the value:

TRAI floats new paper on 'Net Neutrality': Lists disadvantages of zero-rating plans
like image 191
Andreas Avatar answered Jun 19 '26 12:06

Andreas


try this one

str = org.apache.commons.lang.StringEscapeUtils.unescapeJava(str);

refer Apache commons lang

like image 23
JIGAR Avatar answered Jun 19 '26 12:06

JIGAR