0a708025 |
1 | <?php |
4b4abf93 |
2 | |
d6c32258 |
3 | /** |
0a708025 |
4 | * decode/koi8-r.php |
0a708025 |
5 | * |
0a708025 |
6 | * This file contains koi8-r decoding function that is needed to read |
7 | * koi8-r encoded mails in non-koi8-r locale. |
91e0dccc |
8 | * |
0a708025 |
9 | * Original data taken from: |
10 | * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/KOI8-R.TXT |
11 | * |
12 | * Name: KOI8-R (RFC1489) to Unicode |
13 | * Unicode version: 3.0 |
14 | * Table version: 1.0 |
15 | * Table format: Format A |
16 | * Date: 18 August 1999 |
17 | * Authors: Helmut Richter <richter@lrz.de> |
18 | * |
19 | * Copyright (c) 1991-1999 Unicode, Inc. All Rights reserved. |
20 | * |
21 | * This file is provided as-is by Unicode, Inc. (The Unicode Consortium). |
22 | * No claims are made as to fitness for any particular purpose. No |
23 | * warranties of any kind are expressed or implied. The recipient |
24 | * agrees to determine applicability of information provided. If this |
25 | * file has been provided on optical media by Unicode, Inc., the sole |
26 | * remedy for any claim will be exchange of defective media within 90 |
27 | * days of receipt. |
28 | * |
29 | * Unicode, Inc. hereby grants the right to freely use the information |
30 | * supplied in this file in the creation of products supporting the |
31 | * Unicode Standard, and to make copies of this file in any form for |
32 | * internal or external distribution as long as this notice remains |
33 | * attached. |
34 | * |
ae5dddc0 |
35 | * @copyright 2003-2011 The SquirrelMail Project Team |
4b4abf93 |
36 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
31841a9e |
37 | * @version $Id$ |
d6c32258 |
38 | * @package squirrelmail |
39 | * @subpackage decode |
0a708025 |
40 | */ |
41 | |
d6c32258 |
42 | /** |
43 | * Decode koi8r strings |
44 | * @param string $string Encoded string |
45 | * @return string Decoded string |
46 | */ |
df8c4d6d |
47 | function charset_decode_koi8_r ($string) { |
e53c9681 |
48 | // don't do decoding when there are no 8bit symbols |
49 | if (! sq_is8bit($string,'koi8-r')) |
0a708025 |
50 | return $string; |
51 | |
52 | $koi8r = array( |
e53c9681 |
53 | "\x80" => '─', |
54 | "\x81" => '│', |
55 | "\x82" => '┌', |
56 | "\x83" => '┐', |
57 | "\x84" => '└', |
58 | "\x85" => '┘', |
59 | "\x86" => '├', |
60 | "\x87" => '┤', |
61 | "\x88" => '┬', |
62 | "\x89" => '┴', |
63 | "\x8A" => '┼', |
64 | "\x8B" => '▀', |
65 | "\x8C" => '▄', |
66 | "\x8D" => '█', |
67 | "\x8E" => '▌', |
68 | "\x8F" => '▐', |
69 | "\x90" => '░', |
70 | "\x91" => '▒', |
71 | "\x92" => '▓', |
72 | "\x93" => '⌠', |
73 | "\x94" => '■', |
74 | "\x95" => '∙', |
75 | "\x96" => '√', |
76 | "\x97" => '≈', |
77 | "\x98" => '≤', |
78 | "\x99" => '≥', |
79 | "\x9A" => ' ', |
80 | "\x9B" => '⌡', |
81 | "\x9C" => '°', |
82 | "\x9D" => '²', |
83 | "\x9E" => '·', |
84 | "\x9F" => '÷', |
85 | "\xA0" => '═', |
86 | "\xA1" => '║', |
87 | "\xA2" => '╒', |
88 | "\xA3" => 'ё', |
89 | "\xA4" => '╓', |
90 | "\xA5" => '╔', |
91 | "\xA6" => '╕', |
92 | "\xA7" => '╖', |
93 | "\xA8" => '╗', |
94 | "\xA9" => '╘', |
95 | "\xAA" => '╙', |
96 | "\xAB" => '╚', |
97 | "\xAC" => '╛', |
98 | "\xAD" => '╜', |
99 | "\xAE" => '╝', |
100 | "\xAF" => '╞', |
101 | "\xB0" => '╟', |
102 | "\xB1" => '╠', |
103 | "\xB2" => '╡', |
104 | "\xB3" => 'Ё', |
105 | "\xB4" => '╢', |
106 | "\xB5" => '╣', |
107 | "\xB6" => '╤', |
108 | "\xB7" => '╥', |
109 | "\xB8" => '╦', |
110 | "\xB9" => '╧', |
111 | "\xBA" => '╨', |
112 | "\xBB" => '╩', |
113 | "\xBC" => '╪', |
114 | "\xBD" => '╫', |
115 | "\xBE" => '╬', |
116 | "\xBF" => '©', |
117 | "\xC0" => 'ю', |
118 | "\xC1" => 'а', |
119 | "\xC2" => 'б', |
120 | "\xC3" => 'ц', |
121 | "\xC4" => 'д', |
122 | "\xC5" => 'е', |
123 | "\xC6" => 'ф', |
124 | "\xC7" => 'г', |
125 | "\xC8" => 'х', |
126 | "\xC9" => 'и', |
127 | "\xCA" => 'й', |
128 | "\xCB" => 'к', |
129 | "\xCC" => 'л', |
130 | "\xCD" => 'м', |
131 | "\xCE" => 'н', |
132 | "\xCF" => 'о', |
133 | "\xD0" => 'п', |
134 | "\xD1" => 'я', |
135 | "\xD2" => 'р', |
136 | "\xD3" => 'с', |
137 | "\xD4" => 'т', |
138 | "\xD5" => 'у', |
139 | "\xD6" => 'ж', |
140 | "\xD7" => 'в', |
141 | "\xD8" => 'ь', |
142 | "\xD9" => 'ы', |
143 | "\xDA" => 'з', |
144 | "\xDB" => 'ш', |
145 | "\xDC" => 'э', |
146 | "\xDD" => 'щ', |
147 | "\xDE" => 'ч', |
148 | "\xDF" => 'ъ', |
149 | "\xE0" => 'Ю', |
150 | "\xE1" => 'А', |
151 | "\xE2" => 'Б', |
152 | "\xE3" => 'Ц', |
153 | "\xE4" => 'Д', |
154 | "\xE5" => 'Е', |
155 | "\xE6" => 'Ф', |
156 | "\xE7" => 'Г', |
157 | "\xE8" => 'Х', |
158 | "\xE9" => 'И', |
159 | "\xEA" => 'Й', |
160 | "\xEB" => 'К', |
161 | "\xEC" => 'Л', |
162 | "\xED" => 'М', |
163 | "\xEE" => 'Н', |
164 | "\xEF" => 'О', |
165 | "\xF0" => 'П', |
166 | "\xF1" => 'Я', |
167 | "\xF2" => 'Р', |
168 | "\xF3" => 'С', |
169 | "\xF4" => 'Т', |
170 | "\xF5" => 'У', |
171 | "\xF6" => 'Ж', |
172 | "\xF7" => 'В', |
173 | "\xF8" => 'Ь', |
174 | "\xF9" => 'Ы', |
175 | "\xFA" => 'З', |
176 | "\xFB" => 'Ш', |
177 | "\xFC" => 'Э', |
178 | "\xFD" => 'Щ', |
179 | "\xFE" => 'Ч', |
180 | "\xFF" => 'Ъ' |
0a708025 |
181 | ); |
182 | |
183 | $string = str_replace(array_keys($koi8r), array_values($koi8r), $string); |
184 | |
185 | return $string; |
186 | } |