note 40253 added to function.strtr
| From: | christophe at publicityweb dot com | Date: | Thu, 26 Feb 2004 17:04:59 +0000 |
| Subject: | note 40253 added to function.strtr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-65816@lists.php.net to get a copy of this message | ||
Latin1 (iso-8859-1) DONT define chars \x80-\x9f (128-159),
but Windows charset 1252 defines _some_ of them
-- like the infamous msoffice 'magic quotes' (\x92 146).
Dont use those invalid control chars in webpages,
but their html (unicode) entities. See
ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT
or http://www.microsoft.com/typography/unicode/1252.htm
PS: a '?' in the code means the win-cp1252 dont define the given char.
$badlatin1_cp1252_to_htmlent =
array(
'\x80'=>'AC;', '\x81'=>'?',
'\x82'=>'ÉA;', '\x83'=>'À',
'\x84'=>'ÉE;', '\x85'=>'ߪ',
'\x86'=>'ߤ', \x87'=>'ߥ',
'\x88'=>'C6;', '\x89'=>'߮',
'\x8A'=>' ', '\x8B'=>'߷',
'\x8C'=>'˜', '\x8D'=>'?',
'\x8E'=>'D;', '\x8F'=>'?',
'\x90'=>'?', '\x91'=>'ߢ',
'\x92'=>'ߣ', '\x93'=>'ÉC;',
'\x94'=>'ÉD;', '\x95'=>'ߦ',
'\x96'=>'ߝ', '\x97'=>'ߞ',
'\x98'=>'DC;', '\x99'=>'ࡊ',
'\x9A'=>'¡', '\x9B'=>'ËA;',
'\x9C'=>'™', '\x9D'=>'?',
'\x9E'=>'E;', '\x9F'=>'²'
);
$str = strtr($str, $badlatin1_cp1252_to_htmlent);
----
Manual Page -- http://www.php.net/manual/en/function.strtr.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40253
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40253&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40253&report=yes
Search -- http://master.php.net/manage/user-notes.php