Question

I am working with HTML and Unicode text that I'm querying from a database. I'm trying to convert it for proper display in a text view.

Here is the relevant code where I'm attempting the conversion:

ReviewView.setText(Html.fromHtml(URLDecoder.decode(cursor.getString(14), "UTF-8")).toString());

However, it's only partially working. Here is an example of the text I'm working with:

is%20in%20the%20title.%3C/p%3E%3Cstrong%3EBoiled%20Brocoli%3C/strong%3E%3Cbr%20/%3EApparently%20brocoli%20does%20not%20make%20for%20a%20good%20pesto.%20This%20tasted%20like%20brocoli%20I%20used%20to%20cook%20when%20I%20was%20eleven%20at%20home%2C%20which%20is%20to%20say%20I%20don%27t%20really%20remember%20it.%3C/p%3E

I want it to look like:

is in the title.

Boiled Broccoli

Apparently broccoli does not make for a good pesto. This tasted like broccoli I used to cook when I was eleven at home which is to say I don't really remember it.


Instead I'm getting:

is in the title.Boiled Broccoli

Apparently broccoli does not make for a good pesto. This tasted like broccoli I used to cook when I was eleven at home which is to say I don't really remember it.

Any ideas on how to properly decode this?

Thanks!

Was it helpful?

Solution 2

Separating the commands actually fixed this. So on separate lines I complete first the decode then the fromHTML.

OTHER TIPS

The start of the Paragraph tag is wrong. in your case,it starts with a end tag, like this < / p > (added space inside the tags for clarity). Also replace the strong tag with b. It should work now.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top