When you put UTF-8 encoded strings into an XML document you should remember that not all UTF-8 characters are accepted in an XML document http://www.w3.org/TR/REC-xml/#charsets You should strip away the invalid characters, else you’ll have an XML fatal parsing error tossed during parsing. It’s rather easy to accomplish this using the following function.
1 2 3 4 5 6 7 |
<?php /* Remove all UTF-8 Chars that are not acceptable for usin in an XML payload */ function utf8_for_xml($string) { return preg_replace ('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', ' ', $string); } ?> |