Java – How to decode unicode char in Java strings?

How to decode unicode char in Java strings?… here is a solution to the problem.

How to decode unicode char in Java strings?

In my android project, I need to display text with a TextView, but I’m having a very bad problem with the following string. Please someone help me.

Here is my java string:

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

It looks 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 am I going to do? Thanks in advance!

Update:

I’ve tried this code but it doesn’t work for me.

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

I want a solution for all ‘\uxxxx’, such as characters, not just ‘\u0027’.

Solution

Don’t double the backslash:

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

This will have the following value:

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

Related Problems and Solutions