note 40253 modified in function.strtr by vincent
| From: | vincent@php.net | Date: | Fri, 27 Feb 2004 10:35:11 +0000 |
| Subject: | note 40253 modified in function.strtr by vincent | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-65872@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'=>'€', '\x81'=>'?',
'\x82'=>'‚', '\x83'=>'ƒ',
'\x84'=>'„', '\x85'=>'…',
'\x86'=>'†', \x87'=>'‡',
'\x88'=>'ˆ', '\x89'=>'‰',
'\x8A'=>'Š', '\x8B'=>'‹',
'\x8C'=>'Œ', '\x8D'=>'?',
'\x8E'=>'Ž', '\x8F'=>'?',
'\x90'=>'?', '\x91'=>'‘',
'\x92'=>'’', '\x93'=>'“',
'\x94'=>'”', '\x95'=>'•',
'\x96'=>'–', '\x97'=>'—',
'\x98'=>'˜', '\x99'=>'™',
'\x9A'=>'š', '\x9B'=>'›',
'\x9C'=>'œ', '\x9D'=>'?',
'\x9E'=>'ž', '\x9F'=>'Ÿ'
);
$str = strtr($str, $badlatin1_cp1252_to_htmlent);
--was--
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);
http://www.php.net/manual/en/function.strtr.php