3 * cp1256 encoding functions
5 * takes a string of unicode entities and converts it to a cp1256 encoded string
6 * Unsupported characters are replaced with ?.
9 * @copyright Copyright © SquirrelMail Development Team, 2004
10 * @package squirrelmail
15 * Converts string to cp1256
16 * @param string $string text with numeric unicode entities
17 * @return string cp1256 encoded text
19 function charset_encode_cp1256 ($string) {
20 // don't run encoding function, if there is no encoded characters
21 if (! preg_match("'&#[0-9]+;'",$string) ) return $string;
23 $string=preg_replace("/&#([0-9]+);/e","unicodetocp1256('\\1')",$string);
24 // $string=preg_replace("/&#[xX]([0-9A-F]+);/e","unicodetocp1256(hexdec('\\1'))",$string);
30 * Return cp1256 symbol when unicode character number is provided
32 * This function is used internally by charset_encode_cp1256
33 * function. It might be unavailable to other squirrelmail functions.
34 * Don't use it or make sure, that functions/encode/cp1256.php is
37 * @param int $var decimal unicode value
38 * @return string cp1256 character
40 function unicodetocp1256($var) {
42 $cp1256chars=array('160' => "\xA0",
171 if (array_key_exists($var,$cp1256chars)) {
172 $ret=$cp1256chars[$var];