3 * tis-620 encoding functions
5 * takes a string of unicode entities and converts it to a tis-620 encoded string
6 * Unsupported characters are replaced with ?.
9 * @copyright Copyright © 2004-2005 The SquirrelMail Project Team
10 * @package squirrelmail
15 * Converts string to tis-620
16 * @param string $string text with numeric unicode entities
17 * @return string tis-620 encoded text
19 function charset_encode_tis_620 ($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","unicodetotis620('\\1')",$string);
24 // $string=preg_replace("/&#[xX]([0-9A-F]+);/e","unicodetotis620(hexdec('\\1'))",$string);
30 * Return tis-620 symbol when unicode character number is provided
32 * This function is used internally by charset_encode_tis_620
33 * function. It might be unavailable to other SquirrelMail functions.
34 * Don't use it or make sure, that functions/encode/tis_620.php is
37 * @param int $var decimal unicode value
38 * @return string tis-620 character
40 function unicodetotis620($var) {
42 $tis620chars=array('3585' => "\xA1",
130 if (array_key_exists($var,$tis620chars)) {
131 $ret=$tis620chars[$var];