I want to ask what is the best way to use php to remove unwanted special characters like RS? because if I contain such characters in my xml document, it makes the client program parsing failed.
(the data source contains both english and chinese characters)
thx!!
you can use strtr for all special characters codes (is very fast):
$output = strtr($input, "\x1E\x06", " "); // Remove RS and ACK
(there is 2 chars inside the first and 2 spaces inside the second string)
or a range with preg_replace:
$output = preg_replace("/[\x1C-\x1F]/", "", $input); // Remove FS GS RS US
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With