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