211d912f |
1 | <?php |
4b4abf93 |
2 | |
d6c32258 |
3 | /** |
211d912f |
4 | * decode/cp1251.php |
211d912f |
5 | * |
211d912f |
6 | * This file contains cp1251 decoding function that is needed to read |
7 | * cp1251 encoded mails in non-cp1251 locale. |
91e0dccc |
8 | * |
211d912f |
9 | * Original data taken from: |
10 | * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1250.TXT |
11 | * |
12 | * Name: cp1251 to Unicode table |
13 | * Unicode version: 2.0 |
14 | * Table version: 2.01 |
15 | * Table format: Format A |
16 | * Date: 04/15/98 |
17 | * Contact: cpxlate@microsoft.com |
31841a9e |
18 | * |
47ccfad4 |
19 | * @copyright © 2003-2006 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 |
211d912f |
24 | */ |
25 | |
d6c32258 |
26 | /** |
27 | * Decode cp1251-encoded string |
28 | * @param string $string Encoded string |
29 | * @return string $string Decoded string |
30 | */ |
211d912f |
31 | function charset_decode_cp1251 ($string) { |
e53c9681 |
32 | // don't do decoding when there are no 8bit symbols |
33 | if (! sq_is8bit($string,'windows-1251')) |
211d912f |
34 | return $string; |
35 | |
36 | $cp1251 = 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" => 'я' |
211d912f |
165 | ); |
166 | |
167 | $string = str_replace(array_keys($cp1251), array_values($cp1251), $string); |
168 | |
169 | return $string; |
170 | } |