How to get rid of invalid UTF-8 characters

  • Christian Stocker

We aggregate the PHP category from on the Planet PHP website. Unfortunately the input from does sometimes contain invalid UTF-8 characters, which leads to errors in the XML parsing. But the following iconv line gets rid of all invalid UTF-8 characters.

$t = iconv("UTF-8", "UTF-8//IGNORE", $t);

Problem solved ;) (But I also wrote a mail to the people about the problem, 'cause this shouldn't happen in the first place)

Tell us what you think