Today Cyrus 2.2.2-BETA with SASL Initial Client response was released so it
[squirrelmail.git] / functions / decode / tis620.php
CommitLineData
7af26ef8 1<?php
2/*
3 * decode/tis620.php
4 * $Id$
5 *
6 * Copyright (c) 2003 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This file contains tis620 decoding function that is needed to read
10 * tis620 encoded mails in non-tis620 locale.
11 *
12 * Original data taken from:
13 * http://www.inet.co.th/cyberclub/trin/thairef/tis620-iso10646.html
14 *
15 * Original copyright:
16 * Note: The information contained herein is provided as-is. It was
17 * complied from various references given at the end of the page.
18 * The author (trin@mozart.inet.co.th) believes all information
19 * presented here is accurate.
20 *
21 * References
22 * 1. [1]TIS 620-2533 Standard for Thai Character Codes for Computers
23 * (in Thai), [2]Thai Industrial Standards Institute
24 * 2. [3]Thai Information Technology Standards, On-line resources at the
25 * National Electronics and Computer Technology Center (NECTEC)
26 * 3. ISO/IEC 10646-1, [4]ISO/IEC JTC1/SC2
27 * 4. [5]Thai block in Unicode 2.1, [6]Unicode Consortium
28 *
29 * Links
30 * 1. http://www.nectec.or.th/it-standards/std620/std620.htm
31 * 2. http://www.tisi.go.th/
32 * 3. http://www.nectec.or.th/it-standards/
33 * 4. http://wwwold.dkuug.dk/JTC1/SC2/
34 * 5. http://charts.unicode.org/Unicode.charts/normal/U0E00.html
35 * 6. http://www.unicode.org/
36 *
37 */
38function charset_decode_tis620 ($string) {
39 global $default_charset;
40
41 if (strtolower($default_charset) == 'tis-620')
42 return $string;
43
44 /* Only do the slow convert if there are 8-bit characters */
45 /* there is no 0x80-0x9F letters in TIS620 */
46 if ( ! ereg("[\241-\377]", $string) )
47 return $string;
48
49 $tis620 = array(
50 "\xA0" => '&#65535;',
51 "\xA1" => '&#3585;',
52 "\xA2" => '&#3586;',
53 "\xA3" => '&#3587;',
54 "\xA4" => '&#3588;',
55 "\xA5" => '&#3589;',
56 "\xA6" => '&#3590;',
57 "\xA7" => '&#3591;',
58 "\xA8" => '&#3592;',
59 "\xA9" => '&#3593;',
60 "\xAA" => '&#3594;',
61 "\xAB" => '&#3595;',
62 "\xAC" => '&#3596;',
63 "\xAD" => '&#3597;',
64 "\xAE" => '&#3598;',
65 "\xAF" => '&#3599;',
66 "\xB0" => '&#3600;',
67 "\xB1" => '&#3601;',
68 "\xB2" => '&#3602;',
69 "\xB3" => '&#3603;',
70 "\xB4" => '&#3604;',
71 "\xB5" => '&#3605;',
72 "\xB6" => '&#3606;',
73 "\xB7" => '&#3607;',
74 "\xB8" => '&#3608;',
75 "\xB9" => '&#3609;',
76 "\xBA" => '&#3610;',
77 "\xBB" => '&#3611;',
78 "\xBC" => '&#3612;',
79 "\xBD" => '&#3613;',
80 "\xBE" => '&#3614;',
81 "\xBF" => '&#3615;',
82 "\xC0" => '&#3616;',
83 "\xC1" => '&#3617;',
84 "\xC2" => '&#3618;',
85 "\xC3" => '&#3619;',
86 "\xC4" => '&#3620;',
87 "\xC5" => '&#3621;',
88 "\xC6" => '&#3622;',
89 "\xC7" => '&#3623;',
90 "\xC8" => '&#3624;',
91 "\xC9" => '&#3625;',
92 "\xCA" => '&#3626;',
93 "\xCB" => '&#3627;',
94 "\xCC" => '&#3628;',
95 "\xCD" => '&#3629;',
96 "\xCE" => '&#3630;',
97 "\xCF" => '&#3631;',
98 "\xD0" => '&#3632;',
99 "\xD1" => '&#3633;',
100 "\xD2" => '&#3634;',
101 "\xD3" => '&#3635;',
102 "\xD4" => '&#3636;',
103 "\xD5" => '&#3637;',
104 "\xD6" => '&#3638;',
105 "\xD7" => '&#3639;',
106 "\xD8" => '&#3640;',
107 "\xD9" => '&#3641;',
108 "\xDA" => '&#3642;',
109 "\xDB" => '&#65535;',
110 "\xDC" => '&#65535;',
111 "\xDD" => '&#65535;',
112 "\xDE" => '&#65535;',
113 "\xDF" => '&#3647;',
114 "\xE0" => '&#3648;',
115 "\xE1" => '&#3649;',
116 "\xE2" => '&#3650;',
117 "\xE3" => '&#3651;',
118 "\xE4" => '&#3652;',
119 "\xE5" => '&#3653;',
120 "\xE6" => '&#3654;',
121 "\xE7" => '&#3655;',
122 "\xE8" => '&#3656;',
123 "\xE9" => '&#3657;',
124 "\xEA" => '&#3658;',
125 "\xEB" => '&#3659;',
126 "\xEC" => '&#3660;',
127 "\xED" => '&#3661;',
128 "\xEE" => '&#3662;',
129 "\xEF" => '&#3663;',
130 "\xF0" => '&#3664;',
131 "\xF1" => '&#3665;',
132 "\xF2" => '&#3666;',
133 "\xF3" => '&#3667;',
134 "\xF4" => '&#3668;',
135 "\xF5" => '&#3669;',
136 "\xF6" => '&#3670;',
137 "\xF7" => '&#3671;',
138 "\xF8" => '&#3672;',
139 "\xF9" => '&#3673;',
140 "\xFA" => '&#3674;',
141 "\xFB" => '&#3675;',
142 "\xFC" => '&#65535;',
143 "\xFD" => '&#65535;',
144 "\xFE" => '&#65535;',
145 "\xFF" => '&#65535;'
146 );
147
148 $string = str_replace(array_keys($tis620), array_values($tis620), $string);
149
150 return $string;
151}
152
153?>