I have string with "\u00a0" and I need to replace it with "" str_replace fails

Posted by 0plus1 on Stack Overflow See other posts from Stack Overflow or by 0plus1
Published on 2010-04-07T12:49:09Z Indexed on 2010/04/07 13:03 UTC
Read the original article Hit count: 831

Filed under:
|
|

I need to clean a string that comes (copy/pasted) from various office suite (excel, access, word) each with his own set of encoding.

I'm using json_encode for debugging purposes in order to being able to see every single encoded character.

I'm able to clean everything I found so far (\r \n) with str_replace, but with \u00a0 I have no luck.

$string = '[email protected]\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0;[email protected]'; //this is the output from json_encode

$clean = str_replace("\u00a0", "",$string);

returns:

[email protected]\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0;[email protected]

that is exactly the same, it completly ignores \u00a0.

Is there a way around this also I'm feeling I'm reinventing the wheel, is there any function/class that completely strips EVERY possibile char of EVERY possible encoding?

Thank you for your time.

_EDIT_

After the first two replies I need to clarify that my example DOES work because it's the output from json_encode not the actual string!

_EDIT_

© Stack Overflow or respective owner

Related posts about php

Related posts about str-replace