4 * iso-8859-7 encoding functions
6 * takes a string of unicode entities and converts it to a iso-8859-7 encoded string
7 * Unsupported characters are replaced with ?.
9 * @copyright 2004-2019 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-7
18 * @param string $string text with numeric unicode entities
19 * @return string iso-8859-7 encoded text
21 function charset_encode_iso_8859_7 ($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_callback("/&#([0-9]+);/",'unicodetoiso88597',$string);
31 * Return iso-8859-7 symbol when unicode character number is provided
33 * This function is used internally by charset_encode_iso_8859_7
34 * function. It might be unavailable to other SquirrelMail functions.
35 * Don't use it or make sure, that functions/encode/iso_8859_7.php is
38 * @param array $matches array with first element a decimal unicode value
39 * @return string iso-8859-7 character
41 function unicodetoiso88597($matches) {
44 $iso88597chars=array('160' => "\xA0",
136 if (array_key_exists($var,$iso88597chars)) {
137 $ret=$iso88597chars[$var];