e9a71964 |
1 | <?php |
4b4abf93 |
2 | |
d6c32258 |
3 | /** |
e9a71964 |
4 | * decode/cp866.php |
e9a71964 |
5 | * |
e9a71964 |
6 | * This file contains cp866 decoding function that is needed to read |
7 | * cp866 encoded mails in non-cp866 locale. |
91e0dccc |
8 | * |
e9a71964 |
9 | * Original data taken from: |
10 | * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/ |
11 | |
12 | Name: cp866_DOSCyrillicRussian to Unicode table |
13 | Unicode version: 2.0 |
14 | Table version: 2.00 |
15 | Table format: Format A |
16 | Date: 04/24/96 |
17 | Authors: Lori Brownell <loribr@microsoft.com> |
18 | K.D. Chang <a-kchang@microsoft.com> |
19 | The entries are in cp866_DOSCyrillicRussian order |
91e0dccc |
20 | * |
47ccfad4 |
21 | * @copyright © 2003-2006 The SquirrelMail Project Team |
4b4abf93 |
22 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
31841a9e |
23 | * @version $Id$ |
d6c32258 |
24 | * @package squirrelmail |
25 | * @subpackage decode |
e9a71964 |
26 | */ |
27 | |
d6c32258 |
28 | /** |
29 | * Decode a cp866-encoded string |
30 | * @param string $string Encoded string |
31 | * @return string $string Decoded string |
32 | */ |
e9a71964 |
33 | function charset_decode_cp866 ($string) { |
e53c9681 |
34 | // don't do decoding when there are no 8bit symbols |
35 | if (! sq_is8bit($string,'ibm866')) |
e9a71964 |
36 | return $string; |
37 | |
38 | $cp866 = array( |
91e0dccc |
39 | "\x80" => 'А', |
40 | "\x81" => 'Б', |
41 | "\x82" => 'В', |
42 | "\x83" => 'Г', |
43 | "\x84" => 'Д', |
44 | "\x85" => 'Е', |
45 | "\x86" => 'Ж', |
46 | "\x87" => 'З', |
47 | "\x88" => 'И', |
48 | "\x89" => 'Й', |
49 | "\x8a" => 'К', |
50 | "\x8b" => 'Л', |
51 | "\x8c" => 'М', |
52 | "\x8d" => 'Н', |
53 | "\x8e" => 'О', |
54 | "\x8f" => 'П', |
55 | "\x90" => 'Р', |
56 | "\x91" => 'С', |
57 | "\x92" => 'Т', |
58 | "\x93" => 'У', |
59 | "\x94" => 'Ф', |
60 | "\x95" => 'Х', |
61 | "\x96" => 'Ц', |
62 | "\x97" => 'Ч', |
63 | "\x98" => 'Ш', |
64 | "\x99" => 'Щ', |
65 | "\x9a" => 'Ъ', |
66 | "\x9b" => 'Ы', |
67 | "\x9c" => 'Ь', |
68 | "\x9d" => 'Э', |
69 | "\x9e" => 'Ю', |
70 | "\x9f" => 'Я', |
71 | "\xa0" => 'а', |
72 | "\xa1" => 'б', |
73 | "\xa2" => 'в', |
74 | "\xa3" => 'г', |
75 | "\xa4" => 'д', |
76 | "\xa5" => 'е', |
77 | "\xa6" => 'ж', |
78 | "\xa7" => 'з', |
79 | "\xa8" => 'и', |
80 | "\xa9" => 'й', |
81 | "\xaa" => 'к', |
82 | "\xab" => 'л', |
83 | "\xac" => 'м', |
84 | "\xad" => 'н', |
85 | "\xae" => 'о', |
86 | "\xaf" => 'п', |
87 | "\xb0" => '░', |
88 | "\xb1" => '▒', |
89 | "\xb2" => '▓', |
90 | "\xb3" => '│', |
91 | "\xb4" => '┤', |
92 | "\xb5" => '╡', |
93 | "\xb6" => '╢', |
94 | "\xb7" => '╖', |
95 | "\xb8" => '╕', |
96 | "\xb9" => '╣', |
97 | "\xba" => '║', |
98 | "\xbb" => '╗', |
99 | "\xbc" => '╝', |
100 | "\xbd" => '╜', |
101 | "\xbe" => '╛', |
102 | "\xbf" => '┐', |
103 | "\xc0" => '└', |
104 | "\xc1" => '┴', |
105 | "\xc2" => '┬', |
106 | "\xc3" => '├', |
107 | "\xc4" => '─', |
108 | "\xc5" => '┼', |
109 | "\xc6" => '╞', |
110 | "\xc7" => '╟', |
111 | "\xc8" => '╚', |
112 | "\xc9" => '╔', |
113 | "\xca" => '╩', |
114 | "\xcb" => '╦', |
115 | "\xcc" => '╠', |
116 | "\xcd" => '═', |
117 | "\xce" => '╬', |
118 | "\xcf" => '╧', |
119 | "\xd0" => '╨', |
120 | "\xd1" => '╤', |
121 | "\xd2" => '╥', |
122 | "\xd3" => '╙', |
123 | "\xd4" => '╘', |
124 | "\xd5" => '╒', |
125 | "\xd6" => '╓', |
126 | "\xd7" => '╫', |
127 | "\xd8" => '╪', |
128 | "\xd9" => '┘', |
129 | "\xda" => '┌', |
130 | "\xdb" => '█', |
131 | "\xdc" => '▄', |
132 | "\xdd" => '▌', |
133 | "\xde" => '▐', |
134 | "\xdf" => '▀', |
135 | "\xe0" => 'р', |
136 | "\xe1" => 'с', |
137 | "\xe2" => 'т', |
138 | "\xe3" => 'у', |
139 | "\xe4" => 'ф', |
140 | "\xe5" => 'х', |
141 | "\xe6" => 'ц', |
142 | "\xe7" => 'ч', |
143 | "\xe8" => 'ш', |
144 | "\xe9" => 'щ', |
145 | "\xea" => 'ъ', |
146 | "\xeb" => 'ы', |
147 | "\xec" => 'ь', |
148 | "\xed" => 'э', |
149 | "\xee" => 'ю', |
150 | "\xef" => 'я', |
151 | "\xf0" => 'Ё', |
152 | "\xf1" => 'ё', |
153 | "\xf2" => 'Є', |
154 | "\xf3" => 'є', |
155 | "\xf4" => 'Ї', |
156 | "\xf5" => 'ї', |
157 | "\xf6" => 'Ў', |
158 | "\xf7" => 'ў', |
159 | "\xf8" => '°', |
160 | "\xf9" => '∙', |
161 | "\xfa" => '·', |
162 | "\xfb" => '√', |
163 | "\xfc" => '№', |
164 | "\xfd" => '¤', |
165 | "\xfe" => '■', |
166 | "\xff" => ' ' |
e9a71964 |
167 | ); |
168 | |
169 | $string = str_replace(array_keys($cp866), array_values($cp866), $string); |
170 | |
171 | return $string; |
6c99d1de |
172 | } |