How do I remove ASCII number 13?

2020-05-02 03:24发布

问题:

I have always wondered why I can't replace an unknown whitespace character until just an hour ago that I decided to loop through it and using php ord function I found out that it is actually character ASCII number 13. I tried the following to remove it but didn't work:

preg_replace('/\x13/','',$string)

any help?

回答1:

13 in hexadecimal is 19 in decimal, which is the ASCII control character DC3, which isn't properly whitespace.

You probably mean decimal 13, which is a carriage return. In hexadecimal, that's D, so you'd use \x0D instead.