e9a71964 |
1 | <?php |
d6c32258 |
2 | /** |
e9a71964 |
3 | * decode/cp10017.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 cp10017 (MacUkrainian) decoding function that |
10 | * is needed to read cp10017 encoded mails in non-cp10017 locale. |
11 | * |
12 | * Apple states [2] that x-mac-ukrainian differs from x-mac-cyrillic [1] |
13 | * only in two places. According to [3] these symbols are: |
14 | * 0x92 - U+1168 - CYRILLIC CAPITAL LETTER GHE WITH UPTURN |
15 | * 0xD6 - U+1169 - CYRILLIC SMALL LETTER GHE WITH UPTURN |
16 | * |
17 | * References: |
18 | * 1. ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/MAC/CYRILLIC.TXT |
19 | * 2. http://developer.apple.com/documentation/macos8/TextIntlSvcs/TextEncodingConversionManager/TEC1.5/TEC.b0.html |
20 | * 3. http://shlimazl.nm.ru/rus/cptable.htm (page in Russian) |
d6c32258 |
21 | * @package squirrelmail |
22 | * @subpackage decode |
e9a71964 |
23 | */ |
24 | |
d6c32258 |
25 | /** |
26 | * Decode a cp10017 (MacUkrainian) string |
27 | * @param string $string Encoded string |
28 | * @return string $string Decoded string |
29 | */ |
e9a71964 |
30 | function charset_decode_cp10017 ($string) { |
31 | global $default_charset; |
32 | |
33 | if (strtolower($default_charset) == 'x-mac-ukrainian') |
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 | $cp10017 = 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($cp10017), array_values($cp10017), $string); |
173 | |
174 | return $string; |
175 | } |
d6c32258 |
176 | ?> |