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