MySQL Database returns utf8
encoded text. Basically, I used PDO
attribute MYSQL_ATTR_INIT_COMMAND
and passed:
SET CHARACTER SET utf8
It returns utf8
encoded text. But some text in the database is plain utf8
, something like &alum;
are returned as is.
So I need to call utf8_encode
again in php to get the actual utf8
char. Its working fine.
I would like to know, if it will have any negative effect encoding the text twice or it does not affect anything other than encoding the non-encoded text like above?
Thanks!
Edit:
I am using the following code to get the right characters:
$val = utf8_encode(addslashes(html_entity_decode(strip_tags($val))));
So what it does is convert the following text from:
<font color=\"#222222\" face=\"arial, sans-serif\" size=\"2\"> Test Event </font><span style=\"color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px;\">Persönlichkeit Universität"</span>
(This text is coming from the database, after calling the SET CHARACTER SET utf8
)
to:
Test Event Persönlichkeit Universität\"