Page 1 of 1

Removing Unicode Charater 'Right-To-Left Override'

Posted: Wed Dec 06, 2006 8:52 pm
by Tikitiki
http://www.fileformat.info/info/unicode ... /index.htm

I've been trying various ways of how to do this and I am not able to come up with a solution at all. Is anyone able to present me with a way to find and remove the RTL Override character without having to htmlentities() any portion of the string the character is in.

I have tried the following, none of which seem to work:

Code: Select all

$string = str_replace("\u202E", "", $string);

Code: Select all

$string = mb_ereg_replace("\x20\x2E", "", $string);
The following link is the file with the character I would like to be able to remove in PHP. http://www.neowin.net/forum/index.php?a ... &id=170047 (view the source, and highlight it to see the invisible character)

Thanks in Advanced.

Cheers

Posted: Thu Dec 07, 2006 12:58 pm
by feyd
You may need to use chr() to build the binary string to use with str_replace().

Posted: Thu Dec 07, 2006 4:32 pm
by Tikitiki

Code: Select all

$message = str_replace(chr(8238), "REPLACED BY STR FOO", $message);
I tried that but it still doesn't work :(

Posted: Thu Dec 07, 2006 4:51 pm
by feyd
8238 is not a valid character code for chr(). PHP is not unicode in all functions, or any really, until PHP 6 is fully out the door. You will have to build the two (or more) byte string.

Posted: Thu Dec 07, 2006 6:06 pm
by Tikitiki
Not sure how I'd do that?

Thanks for all your help in advanced

Posted: Thu Dec 07, 2006 6:32 pm
by feyd
Well, the code I posted some time ago that converts character numbers into UTF8 character strings may be of use: viewtopic.php?t=36549

Posted: Thu Dec 07, 2006 6:43 pm
by Tikitiki
Thanks a baggilion dude. You've saved my life :P Your the best! Cheers mate!