7af26ef8 |
1 | <?php |
d6c32258 |
2 | /** |
7af26ef8 |
3 | * decode/tis620.php |
7af26ef8 |
4 | * |
82d304a0 |
5 | * Copyright (c) 2003-2004 The SquirrelMail Project Team |
7af26ef8 |
6 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
7 | * |
8 | * This file contains tis620 decoding function that is needed to read |
9 | * tis620 encoded mails in non-tis620 locale. |
10 | * |
11 | * Original data taken from: |
12 | * http://www.inet.co.th/cyberclub/trin/thairef/tis620-iso10646.html |
13 | * |
14 | * Original copyright: |
15 | * Note: The information contained herein is provided as-is. It was |
16 | * complied from various references given at the end of the page. |
17 | * The author (trin@mozart.inet.co.th) believes all information |
18 | * presented here is accurate. |
19 | * |
20 | * References |
21 | * 1. [1]TIS 620-2533 Standard for Thai Character Codes for Computers |
22 | * (in Thai), [2]Thai Industrial Standards Institute |
23 | * 2. [3]Thai Information Technology Standards, On-line resources at the |
24 | * National Electronics and Computer Technology Center (NECTEC) |
25 | * 3. ISO/IEC 10646-1, [4]ISO/IEC JTC1/SC2 |
26 | * 4. [5]Thai block in Unicode 2.1, [6]Unicode Consortium |
27 | * |
28 | * Links |
29 | * 1. http://www.nectec.or.th/it-standards/std620/std620.htm |
30 | * 2. http://www.tisi.go.th/ |
31 | * 3. http://www.nectec.or.th/it-standards/ |
32 | * 4. http://wwwold.dkuug.dk/JTC1/SC2/ |
33 | * 5. http://charts.unicode.org/Unicode.charts/normal/U0E00.html |
34 | * 6. http://www.unicode.org/ |
35 | * |
31841a9e |
36 | * @version $Id$ |
d6c32258 |
37 | * @package squirrelmail |
38 | * @subpackage decode |
39 | */ |
40 | |
41 | /** |
42 | * Decode tis620 encoded strings |
43 | * @param string $string Encoded string |
44 | * @return string Decoded string |
7af26ef8 |
45 | */ |
df8c4d6d |
46 | function charset_decode_tis_620 ($string) { |
7af26ef8 |
47 | global $default_charset; |
48 | |
49 | if (strtolower($default_charset) == 'tis-620') |
50 | return $string; |
51 | |
e53c9681 |
52 | // don't do decoding when there are no 8bit symbols |
53 | if (! sq_is8bit($string,'tis-620')) |
7af26ef8 |
54 | return $string; |
55 | |
56 | $tis620 = array( |
e53c9681 |
57 | "\xA0" => '', |
58 | "\xA1" => 'ก', |
59 | "\xA2" => 'ข', |
60 | "\xA3" => 'ฃ', |
61 | "\xA4" => 'ค', |
62 | "\xA5" => 'ฅ', |
63 | "\xA6" => 'ฆ', |
64 | "\xA7" => 'ง', |
65 | "\xA8" => 'จ', |
66 | "\xA9" => 'ฉ', |
67 | "\xAA" => 'ช', |
68 | "\xAB" => 'ซ', |
69 | "\xAC" => 'ฌ', |
70 | "\xAD" => 'ญ', |
71 | "\xAE" => 'ฎ', |
72 | "\xAF" => 'ฏ', |
73 | "\xB0" => 'ฐ', |
74 | "\xB1" => 'ฑ', |
75 | "\xB2" => 'ฒ', |
76 | "\xB3" => 'ณ', |
77 | "\xB4" => 'ด', |
78 | "\xB5" => 'ต', |
79 | "\xB6" => 'ถ', |
80 | "\xB7" => 'ท', |
81 | "\xB8" => 'ธ', |
82 | "\xB9" => 'น', |
83 | "\xBA" => 'บ', |
84 | "\xBB" => 'ป', |
85 | "\xBC" => 'ผ', |
86 | "\xBD" => 'ฝ', |
87 | "\xBE" => 'พ', |
88 | "\xBF" => 'ฟ', |
89 | "\xC0" => 'ภ', |
90 | "\xC1" => 'ม', |
91 | "\xC2" => 'ย', |
92 | "\xC3" => 'ร', |
93 | "\xC4" => 'ฤ', |
94 | "\xC5" => 'ล', |
95 | "\xC6" => 'ฦ', |
96 | "\xC7" => 'ว', |
97 | "\xC8" => 'ศ', |
98 | "\xC9" => 'ษ', |
99 | "\xCA" => 'ส', |
100 | "\xCB" => 'ห', |
101 | "\xCC" => 'ฬ', |
102 | "\xCD" => 'อ', |
103 | "\xCE" => 'ฮ', |
104 | "\xCF" => 'ฯ', |
105 | "\xD0" => 'ะ', |
106 | "\xD1" => 'ั', |
107 | "\xD2" => 'า', |
108 | "\xD3" => 'ำ', |
109 | "\xD4" => 'ิ', |
110 | "\xD5" => 'ี', |
111 | "\xD6" => 'ึ', |
112 | "\xD7" => 'ื', |
113 | "\xD8" => 'ุ', |
114 | "\xD9" => 'ู', |
115 | "\xDA" => 'ฺ', |
116 | "\xDB" => '', |
117 | "\xDC" => '', |
118 | "\xDD" => '', |
119 | "\xDE" => '', |
120 | "\xDF" => '฿', |
121 | "\xE0" => 'เ', |
122 | "\xE1" => 'แ', |
123 | "\xE2" => 'โ', |
124 | "\xE3" => 'ใ', |
125 | "\xE4" => 'ไ', |
126 | "\xE5" => 'ๅ', |
127 | "\xE6" => 'ๆ', |
128 | "\xE7" => '็', |
129 | "\xE8" => '่', |
130 | "\xE9" => '้', |
131 | "\xEA" => '๊', |
132 | "\xEB" => '๋', |
133 | "\xEC" => '์', |
134 | "\xED" => 'ํ', |
135 | "\xEE" => '๎', |
136 | "\xEF" => '๏', |
137 | "\xF0" => '๐', |
138 | "\xF1" => '๑', |
139 | "\xF2" => '๒', |
140 | "\xF3" => '๓', |
141 | "\xF4" => '๔', |
142 | "\xF5" => '๕', |
143 | "\xF6" => '๖', |
144 | "\xF7" => '๗', |
145 | "\xF8" => '๘', |
146 | "\xF9" => '๙', |
147 | "\xFA" => '๚', |
148 | "\xFB" => '๛', |
149 | "\xFC" => '', |
150 | "\xFD" => '', |
151 | "\xFE" => '', |
152 | "\xFF" => '' |
153 | ); |
7af26ef8 |
154 | |
155 | $string = str_replace(array_keys($tis620), array_values($tis620), $string); |
156 | |
157 | return $string; |
158 | } |
e53c9681 |
159 | ?> |