0a708025 |
1 | <?php |
d6c32258 |
2 | /** |
0a708025 |
3 | * decode/koi8-u.php |
0a708025 |
4 | * |
82d304a0 |
5 | * Copyright (c) 2003-2004 The SquirrelMail Project Team |
0a708025 |
6 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
7 | * |
8 | * This file contains koi8-u decoding function that is needed to read |
9 | * koi8-u encoded mails in non-koi8-u locale. |
10 | * |
11 | * Original data taken from rfc2319 |
12 | * |
13 | * Original copyright: |
14 | * |
15 | * Copyright (C) The Internet Society (1998). All Rights Reserved. |
16 | * |
17 | * This document and translations of it may be copied and furnished to |
18 | * others, and derivative works that comment on or otherwise explain it |
19 | * or assist in its implementation may be prepared, copied, published |
20 | * and distributed, in whole or in part, without restriction of any |
21 | * kind, provided that the above copyright notice and this paragraph are |
22 | * included on all such copies and derivative works. However, this |
23 | * document itself may not be modified in any way, such as by removing |
24 | * the copyright notice or references to the Internet Society or other |
25 | * Internet organizations, except as needed for the purpose of |
26 | * developing Internet standards in which case the procedures for |
27 | * copyrights defined in the Internet Standards process must be |
28 | * followed, or as required to translate it into languages other than |
29 | * English. |
30 | * |
31 | * The limited permissions granted above are perpetual and will not be |
32 | * revoked by the Internet Society or its successors or assigns. |
33 | * |
34 | * This document and the information contained herein is provided on an |
35 | * "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING |
36 | * TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING |
37 | * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION |
38 | * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF |
39 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. |
40 | * |
31841a9e |
41 | * @version $Id$ |
d6c32258 |
42 | * @package squirrelmail |
43 | * @subpackage decode |
44 | */ |
45 | |
46 | /** |
47 | * Decode koi8-u encoded strings |
48 | * @param string $string Encoded string |
49 | * @return string Decoded string |
0a708025 |
50 | */ |
df8c4d6d |
51 | function charset_decode_koi8_u ($string) { |
0a708025 |
52 | global $default_charset; |
53 | |
54 | if (strtolower($default_charset) == 'koi8-u') |
55 | return $string; |
56 | |
57 | /* Only do the slow convert if there are 8-bit characters */ |
58 | /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */ |
59 | if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) ) |
60 | return $string; |
61 | |
62 | $koi8u = array( |
63 | "\x80" => '─', |
64 | "\x81" => '│', |
65 | "\x82" => '┌', |
66 | "\x83" => '┐', |
67 | "\x84" => '└', |
68 | "\x85" => '┘', |
69 | "\x86" => '├', |
70 | "\x87" => '┤', |
71 | "\x88" => '┬', |
72 | "\x89" => '┴', |
73 | "\x8A" => '┼', |
74 | "\x8B" => '▀', |
75 | "\x8C" => '▄', |
76 | "\x8D" => '█', |
77 | "\x8E" => '▌', |
78 | "\x8F" => '▐', |
79 | "\x90" => '░', |
80 | "\x91" => '▒', |
81 | "\x92" => '▓', |
82 | "\x93" => '⌠', |
83 | "\x94" => '■', |
84 | "\x95" => '∙', |
85 | "\x96" => '√', |
86 | "\x97" => '≈', |
87 | "\x98" => '≤', |
88 | "\x99" => '≥', |
89 | "\x9A" => ' ', |
90 | "\x9B" => '⌡', |
91 | "\x9C" => '°', |
92 | "\x9D" => '²', |
93 | "\x9E" => '·', |
94 | "\x9F" => '÷', |
95 | "\xA0" => '═', |
96 | "\xA1" => '║', |
97 | "\xA2" => '╒', |
98 | "\xA3" => 'ё', |
99 | "\xA4" => 'є', |
100 | "\xA5" => '╔', |
101 | "\xA6" => 'і', |
102 | "\xA7" => 'ї', |
103 | "\xA8" => '╗', |
104 | "\xA9" => '╘', |
105 | "\xAA" => '╙', |
106 | "\xAB" => '╚', |
107 | "\xAC" => '╛', |
108 | "\xAD" => 'ґ', |
109 | "\xAE" => '╝', |
110 | "\xAF" => '╞', |
111 | "\xB0" => '╟', |
112 | "\xB1" => '╠', |
113 | "\xB2" => '╡', |
114 | "\xB3" => 'Ё', |
115 | "\xB4" => 'Ѓ', |
116 | "\xB5" => '╣', |
117 | "\xB6" => 'І', |
118 | "\xB7" => 'Ї', |
119 | "\xB8" => '╦', |
120 | "\xB9" => '╧', |
121 | "\xBA" => '╨', |
122 | "\xBB" => '╩', |
123 | "\xBC" => '╪', |
124 | "\xBD" => 'Ґ', |
125 | "\xBE" => '╬', |
126 | "\xBF" => '©', |
127 | "\xC0" => 'ю', |
128 | "\xC1" => 'а', |
129 | "\xC2" => 'б', |
130 | "\xC3" => 'ц', |
131 | "\xC4" => 'д', |
132 | "\xC5" => 'е', |
133 | "\xC6" => 'ф', |
134 | "\xC7" => 'г', |
135 | "\xC8" => 'х', |
136 | "\xC9" => 'и', |
137 | "\xCA" => 'й', |
138 | "\xCB" => 'к', |
139 | "\xCC" => 'л', |
140 | "\xCD" => 'м', |
141 | "\xCE" => 'н', |
142 | "\xCF" => 'о', |
143 | "\xD0" => 'п', |
144 | "\xD1" => 'я', |
145 | "\xD2" => 'р', |
146 | "\xD3" => 'с', |
147 | "\xD4" => 'т', |
148 | "\xD5" => 'у', |
149 | "\xD6" => 'ж', |
150 | "\xD7" => 'в', |
151 | "\xD8" => 'ь', |
152 | "\xD9" => 'ы', |
153 | "\xDA" => 'з', |
154 | "\xDB" => 'ш', |
155 | "\xDC" => 'э', |
156 | "\xDD" => 'щ', |
157 | "\xDE" => 'ч', |
158 | "\xDF" => 'ъ', |
159 | "\xE0" => 'Ю', |
160 | "\xE1" => 'А', |
161 | "\xE2" => 'Б', |
162 | "\xE3" => 'Ц', |
163 | "\xE4" => 'Д', |
164 | "\xE5" => 'Е', |
165 | "\xE6" => 'Ф', |
166 | "\xE7" => 'Г', |
167 | "\xE8" => 'Х', |
168 | "\xE9" => 'И', |
169 | "\xEA" => 'Й', |
170 | "\xEB" => 'К', |
171 | "\xEC" => 'Л', |
172 | "\xED" => 'М', |
173 | "\xEE" => 'Н', |
174 | "\xEF" => 'О', |
175 | "\xF0" => 'П', |
176 | "\xF1" => 'Я', |
177 | "\xF2" => 'Р', |
178 | "\xF3" => 'С', |
179 | "\xF4" => 'Т', |
180 | "\xF5" => 'У', |
181 | "\xF6" => 'Ж', |
182 | "\xF7" => 'В', |
183 | "\xF8" => 'Ь', |
184 | "\xF9" => 'Ы', |
185 | "\xFA" => 'З', |
186 | "\xFB" => 'Ш', |
187 | "\xFC" => 'Э', |
188 | "\xFD" => 'Щ', |
189 | "\xFE" => 'Ч', |
190 | "\xFF" => 'Ъ' |
191 | ); |
192 | |
193 | $string = str_replace(array_keys($koi8u), array_values($koi8u), $string); |
194 | |
195 | return $string; |
196 | } |
197 | |
d6c32258 |
198 | ?> |