NYCPHP Meetup

NYPHP.org

[nycphp-talk] SimpleXML - UTF8

Dan Cech dcech at phpwerx.net
Mon Oct 19 07:32:15 EDT 2009


John Campbell wrote:
> I am using a remote XML service, that about 1 in 100 times returns XML
> with invalid UTF-8 bytes.  I don't have any control over the remote
> service, but simpleXML pukes when I pass malformed UTF-8 to it.  Does
> anyone know of a simple way to cleanup bad UTF-8 bytes, e.g. replace
> the invalid bytes with a '?'.

Try:

$text = @iconv('UTF-8','UTF-8//TRANSLIT',$text);

Dan



More information about the talk mailing list