Posted By

jdbartlett on 09/25/09


Tagged

xml utf8


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

dimispaceman


Strip Illegal XML Characters from a UTF-8 String


 / Published in: PHP
 

Some valid UTF-8 characters are illegal in XML: http://www.w3.org/TR/REC-xml/#charsets

This statement strips them from your strings.

  1. preg_replace('/[^\\x0009\\x000A\\x000D\\x0020-\\xD7FF\\xE000-\\xFFFD]/', ' ', $string);

Report this snippet  

You need to login to post a comment.