0
I’m using htmlentities() in PHP to store data in the database, overwriting c, ã, and other characters by HTML entities:
<?PHP
htmlentities ("Ampliação");
//Resulta na string "Ampliação
In Java (Android) I need to decode these entities to their respective source values ("Magnification"), but I did not find an effective solution, only the function
Stringescapeutils.unescapeHtml4(String)
but it is converting to characters different from the originals, in addition to being depreciated.
The method
Urldecoder.Decoder(String)
Also did not result in the original string.
Any hint?
Why store the string doing the subtituition? It could not save the original string and when it needed to display on an html page it would make the conversion used htmlentities()?
– mari
After hours of trying to set up the database to accept special characters I gave up, I tried everything. PHP is set to UTF-8, in the BD I tried UTF-8, Latin1, of all kinds and nothing worked
– Jhonatan Pereira
I also accept response to configure the database, rather than replacing the characters
– Jhonatan Pereira
In this case it is better to create another question, since others looking for answers to the same question will be based on the title. In this question include as much information as possible: how you are saving in the database (code), which database, what appears when you look at the records in the database (e.g. a direct sql query in the DB and not via application), which "nothing worked" exactly, and whatever else you imagine that might help someone to help you ;-)
– mari
Ever tried to use
Html.fromHtml((String) htmlCode).toString()
?– viana
@acklay, it worked! That’s just it.
– Jhonatan Pereira
Just don’t need the casting inside fromHtml
– Jhonatan Pereira