Reputation: 5221
I am currently pulling in feed data in another languages. I do the following and store into mysql.
$content = htmlentities($item->title, ENT_COMPAT, "UTF-8");
when I output the text, using $this->escape it still escapes the encoded entity.
So I get : á
instead of á
Any idea?
Upvotes: 0
Views: 1093
Reputation: 15945
Don't do htmlentities
, do htmlspecialchars
, htmlentities
encodes many things that need not or even should not be encoded:
$content = htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8');
If the feed data is not encoded in utf-8, you may need to convert it, before htmlspecialchars
:
$content = mb_convert_encoding($item->title, 'UTF-8', '<encoding of the other side>');
Note that "encoding of the other side" may prove important.
By the way, if you are going to output it as HTML without any filtering, consider storing it as native HTML.
Upvotes: 1