211d912f |
1 | <?php |
d6c32258 |
2 | /** |
211d912f |
3 | * decode/cp1252.php |
211d912f |
4 | * |
82d304a0 |
5 | * Copyright (c) 2003-2004 The SquirrelMail Project Team |
211d912f |
6 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
7 | * |
8 | * This file contains cp1252 decoding function that is needed to read |
9 | * cp1252 encoded mails in non-cp1252 locale. |
10 | * |
11 | * Original data taken from: |
12 | * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT |
13 | * |
14 | * Name: cp1252 to Unicode table |
15 | * Unicode version: 2.0 |
16 | * Table version: 2.01 |
17 | * Table format: Format A |
18 | * Date: 04/15/98 |
19 | * Contact: cpxlate@microsoft.com |
31841a9e |
20 | * |
21 | * @version $Id$ |
d6c32258 |
22 | * @package squirrelmail |
23 | * @subpackage decode |
24 | */ |
25 | |
26 | /** |
27 | * Decode cp1252-encoded string |
28 | * @param string $string Encoded string |
29 | * @return string $string Decoded string |
211d912f |
30 | */ |
31 | |
32 | function charset_decode_cp1252 ($string) { |
33 | global $default_charset; |
34 | |
35 | if (strtolower($default_charset) == 'windows-1252') |
36 | return $string; |
37 | |
38 | /* Only do the slow convert if there are 8-bit characters */ |
39 | /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */ |
40 | if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) ) |
41 | return $string; |
42 | |
43 | $cp1252 = array( |
44 | "\x80" => '€', |
45 | "\x81" => '�', |
46 | "\x82" => '‚', |
47 | "\x83" => 'ƒ', |
48 | "\x84" => '„', |
49 | "\x85" => '…', |
50 | "\x86" => '†', |
51 | "\x87" => '‡', |
52 | "\x88" => 'ˆ', |
53 | "\x89" => '‰', |
54 | "\x8A" => 'Š', |
55 | "\x8B" => '‹', |
56 | "\x8C" => 'Œ', |
57 | "\x8D" => '�', |
58 | "\x8E" => 'Ž', |
59 | "\x8F" => '�', |
60 | "\x90" => '�', |
61 | "\x91" => '‘', |
62 | "\x92" => '’', |
63 | "\x93" => '“', |
64 | "\x94" => '”', |
65 | "\x95" => '•', |
66 | "\x96" => '–', |
67 | "\x97" => '—', |
68 | "\x98" => '˜', |
69 | "\x99" => '™', |
70 | "\x9A" => 'š', |
71 | "\x9B" => '›', |
72 | "\x9C" => 'œ', |
73 | "\x9D" => '�', |
74 | "\x9E" => 'ž', |
75 | "\x9F" => 'Ÿ', |
76 | "\xA0" => ' ', |
77 | "\xA1" => '¡', |
78 | "\xA2" => '¢', |
79 | "\xA3" => '£', |
80 | "\xA4" => '¤', |
81 | "\xA5" => '¥', |
82 | "\xA6" => '¦', |
83 | "\xA7" => '§', |
84 | "\xA8" => '¨', |
85 | "\xA9" => '©', |
86 | "\xAA" => 'ª', |
87 | "\xAB" => '«', |
88 | "\xAC" => '¬', |
89 | "\xAD" => '­', |
90 | "\xAE" => '®', |
91 | "\xAF" => '¯', |
92 | "\xB0" => '°', |
93 | "\xB1" => '±', |
94 | "\xB2" => '²', |
95 | "\xB3" => '³', |
96 | "\xB4" => '´', |
97 | "\xB5" => 'µ', |
98 | "\xB6" => '¶', |
99 | "\xB7" => '·', |
100 | "\xB8" => '¸', |
101 | "\xB9" => '¹', |
102 | "\xBA" => 'º', |
103 | "\xBB" => '»', |
104 | "\xBC" => '¼', |
105 | "\xBD" => '½', |
106 | "\xBE" => '¾', |
107 | "\xBF" => '¿', |
108 | "\xC0" => 'À', |
109 | "\xC1" => 'Á', |
110 | "\xC2" => 'Â', |
111 | "\xC3" => 'Ã', |
112 | "\xC4" => 'Ä', |
113 | "\xC5" => 'Å', |
114 | "\xC6" => 'Æ', |
115 | "\xC7" => 'Ç', |
116 | "\xC8" => 'È', |
117 | "\xC9" => 'É', |
118 | "\xCA" => 'Ê', |
119 | "\xCB" => 'Ë', |
120 | "\xCC" => 'Ì', |
121 | "\xCD" => 'Í', |
122 | "\xCE" => 'Î', |
123 | "\xCF" => 'Ï', |
124 | "\xD0" => 'Ð', |
125 | "\xD1" => 'Ñ', |
126 | "\xD2" => 'Ò', |
127 | "\xD3" => 'Ó', |
128 | "\xD4" => 'Ô', |
129 | "\xD5" => 'Õ', |
130 | "\xD6" => 'Ö', |
131 | "\xD7" => '×', |
132 | "\xD8" => 'Ø', |
133 | "\xD9" => 'Ù', |
134 | "\xDA" => 'Ú', |
135 | "\xDB" => 'Û', |
136 | "\xDC" => 'Ü', |
137 | "\xDD" => 'Ý', |
138 | "\xDE" => 'Þ', |
139 | "\xDF" => 'ß', |
140 | "\xE0" => 'à', |
141 | "\xE1" => 'á', |
142 | "\xE2" => 'â', |
143 | "\xE3" => 'ã', |
144 | "\xE4" => 'ä', |
145 | "\xE5" => 'å', |
146 | "\xE6" => 'æ', |
147 | "\xE7" => 'ç', |
148 | "\xE8" => 'è', |
149 | "\xE9" => 'é', |
150 | "\xEA" => 'ê', |
151 | "\xEB" => 'ë', |
152 | "\xEC" => 'ì', |
153 | "\xED" => 'í', |
154 | "\xEE" => 'î', |
155 | "\xEF" => 'ï', |
156 | "\xF0" => 'ð', |
157 | "\xF1" => 'ñ', |
158 | "\xF2" => 'ò', |
159 | "\xF3" => 'ó', |
160 | "\xF4" => 'ô', |
161 | "\xF5" => 'õ', |
162 | "\xF6" => 'ö', |
163 | "\xF7" => '÷', |
164 | "\xF8" => 'ø', |
165 | "\xF9" => 'ù', |
166 | "\xFA" => 'ú', |
167 | "\xFB" => 'û', |
168 | "\xFC" => 'ü', |
169 | "\xFD" => 'ý', |
170 | "\xFE" => 'þ', |
171 | "\xFF" => 'ÿ' |
172 | ); |
173 | |
174 | $string = str_replace(array_keys($cp1252), array_values($cp1252), $string); |
175 | |
176 | return $string; |
177 | } |
178 | |
d6c32258 |
179 | ?> |