note 40253 modified in function.strtr by vincent

From: 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'=>'&#20AC;', '\x81'=>'?', '\x82'=>'&#201A;', '\x83'=>'À', '\x84'=>'&#201E;', '\x85'=>'ߪ', '\x86'=>'ߤ', \x87'=>'ߥ', '\x88'=>'&#02C6;', '\x89'=>'߮', '\x8A'=>' ', '\x8B'=>'߷', '\x8C'=>'˜', '\x8D'=>'?', '\x8E'=>'&#017D;', '\x8F'=>'?', '\x90'=>'?', '\x91'=>'ߢ', '\x92'=>'ߣ', '\x93'=>'&#201C;', '\x94'=>'&#201D;', '\x95'=>'ߦ', '\x96'=>'ߝ', '\x97'=>'ߞ', '\x98'=>'&#02DC;', '\x99'=>'ࡊ', '\x9A'=>'¡', '\x9B'=>'&#203A;', '\x9C'=>'™', '\x9D'=>'?', '\x9E'=>'&#017E;', '\x9F'=>'²' ); $str = strtr($str, $badlatin1_cp1252_to_htmlent); http://www.php.net/manual/en/function.strtr.php

« previous php.notes (#65872) next »