4 * iso-8859-15 encoding functions
6 * takes a string of unicode entities and converts it to a iso-8859-15 encoded string
7 * Unsupported characters are replaced with ?.
9 * @copyright 2004-2011 The SquirrelMail Project Team
10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 * @package squirrelmail
17 * Converts string to iso-8859-15
18 * @param string $string text with numeric unicode entities
19 * @return string iso-8859-15 encoded text
21 function charset_encode_iso_8859_15 ($string) {
22 // don't run encoding function, if there is no encoded characters
23 if (! preg_match("'&#[0-9]+;'",$string) ) return $string;
25 $string=preg_replace("/&#([0-9]+);/e","unicodetoiso885915('\\1')",$string);
26 // $string=preg_replace("/&#[xX]([0-9A-F]+);/e","unicodetoiso885915(hexdec('\\1'))",$string);
32 * Return iso-8859-15 symbol when unicode character number is provided
34 * This function is used internally by charset_encode_iso_8859_15
35 * function. It might be unavailable to other SquirrelMail functions.
36 * Don't use it or make sure, that functions/encode/iso_8859_15.php is
39 * @param int $var decimal unicode value
40 * @return string iso-8859-15 character
42 function unicodetoiso885915($var) {
44 $iso885915chars=array('160' => "\xA0",
141 if (array_key_exists($var,$iso885915chars)) {
142 $ret=$iso885915chars[$var];