Return to Snippet

Revision: 18275
at September 25, 2009 10:35 by jdbartlett


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

Initial URL


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

This statement strips them from your strings.

Initial Title
Strip Illegal XML Characters from a UTF-8 String

Initial Tags
xml

Initial Language
PHP