I have the following string:
Hello. Hello.
If you look at the string in a hex editor it looks like this:
48 65 6C 6C 6F 2E 20 A0 20 20 48 65 6C 6C 6F 2E
Note the A0
in the middle. (This is the no-break space character).
A0
is breaking some JavaScript I am using so I would like to remove it when the string is being pre-processed by a PHP script.
If I use the following code:
$text = preg_replace("/\xA0/"," ", $text);
the A0
gets replaced with 00
which is also a troublesome character.
As you can see from the preg_replace
function, it should be replace by a space, or 20
.
Do any of you know how I can get rid of this troublesome A0
character?
Thank you.
EDIT: I am using Windows-1252 and cannot switch to UTF-8. This won't be a problem if you are using UTF-8...