Removing Unicode Charater 'Right-To-Left Override'

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Tikitiki
Forum Newbie
Posts: 4
Joined: Wed Dec 06, 2006 8:48 pm

Removing Unicode Charater 'Right-To-Left Override'

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You may need to use chr() to build the binary string to use with str_replace().
Tikitiki
Forum Newbie
Posts: 4
Joined: Wed Dec 06, 2006 8:48 pm

Post by Tikitiki »

Code: Select all

$message = str_replace(chr(8238), "REPLACED BY STR FOO", $message);
I tried that but it still doesn't work :(
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Tikitiki
Forum Newbie
Posts: 4
Joined: Wed Dec 06, 2006 8:48 pm

Post by Tikitiki »

Not sure how I'd do that?

Thanks for all your help in advanced
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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
Tikitiki
Forum Newbie
Posts: 4
Joined: Wed Dec 06, 2006 8:48 pm

Post by Tikitiki »

Thanks a baggilion dude. You've saved my life :P Your the best! Cheers mate!
Post Reply