note 37614 deleted from function.htmlentities by cece

From: Date: Sun, 14 Nov 2004 13:36:37 +0000
Subject: note 37614 deleted from function.htmlentities by cece
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-80505@lists.php.net to get a copy of this message
Note Submitter: marcus at synchromedia dot co dot uk ---- The function below does a direct MacRoman to ISO 8859-1 charset conversion. It also avoids the problem of having to have foreign chars in your scripts (see user notes for strtr()) by using hex character codes. Make sure you remove all the line breaks from within the conversion strings. This is posted as an alternative to the script provided by dmurphy at telegeography dot com in the notes for this function, rather than the notes for strtr (perhaps I should post it in both places?). That script is pretty inefficient, particulaly as many strings will be shorter than the table that's scanned on every pass, and he forgot to quote 'key' and 'value'. It does have the advantage of handling 'odd' charcters quite neatly though. <?php /** * Convert MacRoman encoded string into an ISO-8859-1 encoded string * Loses a few odd chars (ligatures etc) that are not in ISO 8859-1 * Adapted from http://www.entropy.ch/software/ * perl/conversion-scripts/convert_mac2iso.pl.txt */ function macroman2iso($macstring){ return strtr($macstring, "\\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\\xa1\\xa4\\xa6\\xa7\\xa8 \\xab\\xac\\xae\\xaf\\xb4\\xbb\\xbc\\xbe\\xbf\\xc0\\xc1\\xc2\\xc7\\xc8 \\xca\\xcb\\xcc\\xd6\\xd8\\xdb\\xe1\\xe5\\xe6\\xe7\\xe8\\xe9\\xea\\xeb \\xec\\xed\\xee\\xef\\xf1\\xf2\\xf3\\xf4\\xf8\\xfc", "\\xc4\\xc5\\xc7\\xc9\\xd1\\xd6\\xdc\\xe1\\xe0\\xe2\\xe4\\xe3 \\xe5\\xe7\\xe9\\xe8\\xea\\xeb\\xed\\xec\\xee\\xef\\xf1\\xf3\\xf2\\xf4 \\xf6\\xf5\\xfa\\xf9\\xfb\\xfc\\xb0\\xa7\\xb6\\xdf\\xae\\xb4\\xa8 \\xc6\\xd8\\xa5\\xaa\\xba\\xe6\\xf8\\xbf\\xa1\\xac\\xab\\xbb \\xa0\\xc0\\xc3\\xf7\\xff\\xa4\\xb7\\xc2\\xca\\xc1\\xcb\\xc8\\xcd \\xce\\xcf\\xcc\\xd3\\xd4\\xd2\\xda\\xdb\\xd9\\xaf\\xb8" ); } ?>

« previous php.notes (#80505) next »