Strip non-printable characters from an UTF-8 string for usage in XML

Spardroma

New Member
Some special characters inside a XML stream may break it. I need to sanitize the data i want to insert in such a stream so that 1) it doesn't corrupt 2) printable UTF-8 characters in it keeps working.I also need to flush the output out as soon as i generate it, else i would have to keep a lot of stuff in ram.As of now, i do something like\[code\]$return = preg_replace('/[^\p{L}\s]/u', '', $return);\[/code\]It removes most of not printable characters, but not all of them. I'm having my hard times trying to figure out what characters are causing this problem, however the terminal returns "1;2c " when i encounter one of them.Do you have any better way to strip out all of these ugly characters?
 
Back
Top