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 | */ |
38 | function 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" => '', |
51 | "\xA1" => 'ก', |
52 | "\xA2" => 'ข', |
53 | "\xA3" => 'ฃ', |
54 | "\xA4" => 'ค', |
55 | "\xA5" => 'ฅ', |
56 | "\xA6" => 'ฆ', |
57 | "\xA7" => 'ง', |
58 | "\xA8" => 'จ', |
59 | "\xA9" => 'ฉ', |
60 | "\xAA" => 'ช', |
61 | "\xAB" => 'ซ', |
62 | "\xAC" => 'ฌ', |
63 | "\xAD" => 'ญ', |
64 | "\xAE" => 'ฎ', |
65 | "\xAF" => 'ฏ', |
66 | "\xB0" => 'ฐ', |
67 | "\xB1" => 'ฑ', |
68 | "\xB2" => 'ฒ', |
69 | "\xB3" => 'ณ', |
70 | "\xB4" => 'ด', |
71 | "\xB5" => 'ต', |
72 | "\xB6" => 'ถ', |
73 | "\xB7" => 'ท', |
74 | "\xB8" => 'ธ', |
75 | "\xB9" => 'น', |
76 | "\xBA" => 'บ', |
77 | "\xBB" => 'ป', |
78 | "\xBC" => 'ผ', |
79 | "\xBD" => 'ฝ', |
80 | "\xBE" => 'พ', |
81 | "\xBF" => 'ฟ', |
82 | "\xC0" => 'ภ', |
83 | "\xC1" => 'ม', |
84 | "\xC2" => 'ย', |
85 | "\xC3" => 'ร', |
86 | "\xC4" => 'ฤ', |
87 | "\xC5" => 'ล', |
88 | "\xC6" => 'ฦ', |
89 | "\xC7" => 'ว', |
90 | "\xC8" => 'ศ', |
91 | "\xC9" => 'ษ', |
92 | "\xCA" => 'ส', |
93 | "\xCB" => 'ห', |
94 | "\xCC" => 'ฬ', |
95 | "\xCD" => 'อ', |
96 | "\xCE" => 'ฮ', |
97 | "\xCF" => 'ฯ', |
98 | "\xD0" => 'ะ', |
99 | "\xD1" => 'ั', |
100 | "\xD2" => 'า', |
101 | "\xD3" => 'ำ', |
102 | "\xD4" => 'ิ', |
103 | "\xD5" => 'ี', |
104 | "\xD6" => 'ึ', |
105 | "\xD7" => 'ื', |
106 | "\xD8" => 'ุ', |
107 | "\xD9" => 'ู', |
108 | "\xDA" => 'ฺ', |
109 | "\xDB" => '', |
110 | "\xDC" => '', |
111 | "\xDD" => '', |
112 | "\xDE" => '', |
113 | "\xDF" => '฿', |
114 | "\xE0" => 'เ', |
115 | "\xE1" => 'แ', |
116 | "\xE2" => 'โ', |
117 | "\xE3" => 'ใ', |
118 | "\xE4" => 'ไ', |
119 | "\xE5" => 'ๅ', |
120 | "\xE6" => 'ๆ', |
121 | "\xE7" => '็', |
122 | "\xE8" => '่', |
123 | "\xE9" => '้', |
124 | "\xEA" => '๊', |
125 | "\xEB" => '๋', |
126 | "\xEC" => '์', |
127 | "\xED" => 'ํ', |
128 | "\xEE" => '๎', |
129 | "\xEF" => '๏', |
130 | "\xF0" => '๐', |
131 | "\xF1" => '๑', |
132 | "\xF2" => '๒', |
133 | "\xF3" => '๓', |
134 | "\xF4" => '๔', |
135 | "\xF5" => '๕', |
136 | "\xF6" => '๖', |
137 | "\xF7" => '๗', |
138 | "\xF8" => '๘', |
139 | "\xF9" => '๙', |
140 | "\xFA" => '๚', |
141 | "\xFB" => '๛', |
142 | "\xFC" => '', |
143 | "\xFD" => '', |
144 | "\xFE" => '', |
145 | "\xFF" => '' |
146 | ); |
147 | |
148 | $string = str_replace(array_keys($tis620), array_values($tis620), $string); |
149 | |
150 | return $string; |
151 | } |
152 | |
153 | ?> |