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