note 14482 deleted from function.strtr by felipe

From: Date: Sat, 29 Dec 2007 21:53:54 +0000
Subject: note 14482 deleted from function.strtr by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-134256@lists.php.net to get a copy of this message
Note Submitter: persiflage2000 at yahoo dot com ---- To replace unicode characters with their ascii equivalents, use $my_string = strtr($my_string, $unicode_array); using this array: $unicode_array = array( "–" => "-", "—" => "-", "–" => "-", "‘" => "'", "’" => "'", "’" => "'", "‘" => "'", "…" => "...", "…" => "...", "“" => "\"", "“" => "\"", "”" => "\"", "”" => "\"", ); It is important to note you need both the unicode contol character (”) AND its text equivalent (”). For instance, text copied and pasted into your html form from M$ Word will have the control character, whereas the same text viewed in a browser and copied into your html form using drag-and-drop will have the text equivalent. A pox on Redmond for the way M$ Word is set to convert all these characters to unicode equivalents by default. Note: you can expand the array to get rid of accented characters too, but remember the same thing applies. For example, both "Š" => "S" and "Š" => "S" should be added to the array.

« previous php.notes (#134256) next »