e9a71964 |
1 | <?php |
d6c32258 |
2 | /** |
e9a71964 |
3 | * decode/cp855.php |
4 | * $Id$ |
5 | * |
82d304a0 |
6 | * Copyright (c) 2003-2004 The SquirrelMail Project Team |
e9a71964 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * This file contains cp855 decoding function that is needed to read |
10 | * cp855 encoded mails in non-cp855 locale. |
11 | * |
12 | * Original data taken from: |
13 | * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP855.TXT |
14 | * Name: cp855_DOSCyrillic to Unicode table |
15 | * Unicode version: 2.0 |
16 | * Table version: 2.00 |
17 | * Table format: Format A |
18 | * Date: 04/24/96 |
19 | * Authors: Lori Brownell <loribr@microsoft.com> |
20 | * K.D. Chang <a-kchang@microsoft.com> |
d6c32258 |
21 | * @package squirrelmail |
22 | * @subpackage decode |
e9a71964 |
23 | */ |
24 | |
d6c32258 |
25 | /** |
26 | * Decode a cp855-encoded string |
27 | * @param string $string Encoded string |
28 | * @return string $string Decoded string |
29 | */ |
e9a71964 |
30 | function charset_decode_cp855 ($string) { |
31 | global $default_charset; |
32 | |
33 | if (strtolower($default_charset) == 'ibm855') |
34 | return $string; |
35 | |
36 | /* Only do the slow convert if there are 8-bit characters */ |
37 | /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */ |
38 | if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) ) |
39 | return $string; |
40 | |
41 | $cp855 = array( |
42 | "\x80" => 'ђ', |
43 | "\x81" => 'Ђ', |
44 | "\x82" => 'ѓ', |
45 | "\x83" => 'Ѓ', |
46 | "\x84" => 'ё', |
47 | "\x85" => 'Ё', |
48 | "\x86" => 'є', |
49 | "\x87" => 'Є', |
50 | "\x88" => 'ѕ', |
51 | "\x89" => 'Ѕ', |
52 | "\x8a" => 'і', |
53 | "\x8b" => 'І', |
54 | "\x8c" => 'ї', |
55 | "\x8d" => 'Ї', |
56 | "\x8e" => 'ј', |
57 | "\x8f" => 'Ј', |
58 | "\x90" => 'љ', |
59 | "\x91" => 'Љ', |
60 | "\x92" => 'њ', |
61 | "\x93" => 'Њ', |
62 | "\x94" => 'ћ', |
63 | "\x95" => 'Ћ', |
64 | "\x96" => 'ќ', |
65 | "\x97" => 'Ќ', |
66 | "\x98" => 'ў', |
67 | "\x99" => 'Ў', |
68 | "\x9a" => 'џ', |
69 | "\x9b" => 'Џ', |
70 | "\x9c" => 'ю', |
71 | "\x9d" => 'Ю', |
72 | "\x9e" => 'ъ', |
73 | "\x9f" => 'Ъ', |
74 | "\xa0" => 'а', |
75 | "\xa1" => 'А', |
76 | "\xa2" => 'б', |
77 | "\xa3" => 'Б', |
78 | "\xa4" => 'ц', |
79 | "\xa5" => 'Ц', |
80 | "\xa6" => 'д', |
81 | "\xa7" => 'Д', |
82 | "\xa8" => 'е', |
83 | "\xa9" => 'Е', |
84 | "\xaa" => 'ф', |
85 | "\xab" => 'Ф', |
86 | "\xac" => 'г', |
87 | "\xad" => 'Г', |
88 | "\xae" => '«', |
89 | "\xaf" => '»', |
90 | "\xb0" => '░', |
91 | "\xb1" => '▒', |
92 | "\xb2" => '▓', |
93 | "\xb3" => '│', |
94 | "\xb4" => '┤', |
95 | "\xb5" => 'х', |
96 | "\xb6" => 'Х', |
97 | "\xb7" => 'и', |
98 | "\xb8" => 'И', |
99 | "\xb9" => '╣', |
100 | "\xba" => '║', |
101 | "\xbb" => '╗', |
102 | "\xbc" => '╝', |
103 | "\xbd" => 'й', |
104 | "\xbe" => 'Й', |
105 | "\xbf" => '┐', |
106 | "\xc0" => '└', |
107 | "\xc1" => '┴', |
108 | "\xc2" => '┬', |
109 | "\xc3" => '├', |
110 | "\xc4" => '─', |
111 | "\xc5" => '┼', |
112 | "\xc6" => 'к', |
113 | "\xc7" => 'К', |
114 | "\xc8" => '╚', |
115 | "\xc9" => '╔', |
116 | "\xca" => '╩', |
117 | "\xcb" => '╦', |
118 | "\xcc" => '╠', |
119 | "\xcd" => '═', |
120 | "\xce" => '╬', |
121 | "\xcf" => '¤', |
122 | "\xd0" => 'л', |
123 | "\xd1" => 'Л', |
124 | "\xd2" => 'м', |
125 | "\xd3" => 'М', |
126 | "\xd4" => 'н', |
127 | "\xd5" => 'Н', |
128 | "\xd6" => 'о', |
129 | "\xd7" => 'О', |
130 | "\xd8" => 'п', |
131 | "\xd9" => '┘', |
132 | "\xda" => '┌', |
133 | "\xdb" => '█', |
134 | "\xdc" => '▄', |
135 | "\xdd" => 'П', |
136 | "\xde" => 'я', |
137 | "\xdf" => '▀', |
138 | "\xe0" => 'Я', |
139 | "\xe1" => 'р', |
140 | "\xe2" => 'Р', |
141 | "\xe3" => 'с', |
142 | "\xe4" => 'С', |
143 | "\xe5" => 'т', |
144 | "\xe6" => 'Т', |
145 | "\xe7" => 'у', |
146 | "\xe8" => 'У', |
147 | "\xe9" => 'ж', |
148 | "\xea" => 'Ж', |
149 | "\xeb" => 'в', |
150 | "\xec" => 'В', |
151 | "\xed" => 'ь', |
152 | "\xee" => 'Ь', |
153 | "\xef" => '№', |
154 | "\xf0" => '­', |
155 | "\xf1" => 'ы', |
156 | "\xf2" => 'Ы', |
157 | "\xf3" => 'з', |
158 | "\xf4" => 'З', |
159 | "\xf5" => 'ш', |
160 | "\xf6" => 'Ш', |
161 | "\xf7" => 'э', |
162 | "\xf8" => 'Э', |
163 | "\xf9" => 'щ', |
164 | "\xfa" => 'Щ', |
165 | "\xfb" => 'ч', |
166 | "\xfc" => 'Ч', |
167 | "\xfd" => '§', |
168 | "\xfe" => '■', |
169 | "\xff" => ' ' |
170 | ); |
171 | |
172 | $string = str_replace(array_keys($cp855), array_values($cp855), $string); |
173 | |
174 | return $string; |
175 | } |
176 | |
d6c32258 |
177 | ?> |