Reputation: 23037
How to use UTF-8
characters in a PHP-script?
I know there is an escape character to interpret the next two characters as UTF-8
. That escape is \s
. So \xFF
works, which will represent 'ÿ
'.
But now I want to remove zero-width spaces (U+200B
) from a string. How to do that? Can I use the function str_replace()
, or maybe preg_replace()
?
Thanks in advance.
Upvotes: 4
Views: 2375
Reputation: 7656
This worked for me:
$str = str_replace("\xe2\x80\x8b", '', $str);
Sources:
Upvotes: 11
Reputation: 746
You may want to try mb_ereg_replace()
or iconv()
with str_replace.
http://www.php.net/manual/en/function.mb-ereg-replace.php
http://hu.php.net/manual/en/function.iconv.php
Upvotes: 0