Today Cyrus 2.2.2-BETA with SASL Initial Client response was released so it
[squirrelmail.git] / functions / decode / cp1252.php
1 <?php
2 /*
3 * decode/cp1252.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 cp1252 decoding function that is needed to read
10 * cp1252 encoded mails in non-cp1252 locale.
11 *
12 * Original data taken from:
13 * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT
14 *
15 * Name: cp1252 to Unicode table
16 * Unicode version: 2.0
17 * Table version: 2.01
18 * Table format: Format A
19 * Date: 04/15/98
20 * Contact: cpxlate@microsoft.com
21 *
22 */
23
24 function charset_decode_cp1252 ($string) {
25 global $default_charset;
26
27 if (strtolower($default_charset) == 'windows-1252')
28 return $string;
29
30 /* Only do the slow convert if there are 8-bit characters */
31 /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
32 if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
33 return $string;
34
35 $cp1252 = array(
36 "\x80" => '&#8364;',
37 "\x81" => '&#65533;',
38 "\x82" => '&#8218;',
39 "\x83" => '&#402;',
40 "\x84" => '&#8222;',
41 "\x85" => '&#8230;',
42 "\x86" => '&#8224;',
43 "\x87" => '&#8225;',
44 "\x88" => '&#710;',
45 "\x89" => '&#8240;',
46 "\x8A" => '&#352;',
47 "\x8B" => '&#8249;',
48 "\x8C" => '&#338;',
49 "\x8D" => '&#65533;',
50 "\x8E" => '&#381;',
51 "\x8F" => '&#65533;',
52 "\x90" => '&#65533;',
53 "\x91" => '&#8216;',
54 "\x92" => '&#8217;',
55 "\x93" => '&#8220;',
56 "\x94" => '&#8221;',
57 "\x95" => '&#8226;',
58 "\x96" => '&#8211;',
59 "\x97" => '&#8212;',
60 "\x98" => '&#732;',
61 "\x99" => '&#8482;',
62 "\x9A" => '&#353;',
63 "\x9B" => '&#8250;',
64 "\x9C" => '&#339;',
65 "\x9D" => '&#65533;',
66 "\x9E" => '&#382;',
67 "\x9F" => '&#376;',
68 "\xA0" => '&#160;',
69 "\xA1" => '&#161;',
70 "\xA2" => '&#162;',
71 "\xA3" => '&#163;',
72 "\xA4" => '&#164;',
73 "\xA5" => '&#165;',
74 "\xA6" => '&#166;',
75 "\xA7" => '&#167;',
76 "\xA8" => '&#168;',
77 "\xA9" => '&#169;',
78 "\xAA" => '&#170;',
79 "\xAB" => '&#171;',
80 "\xAC" => '&#172;',
81 "\xAD" => '&#173;',
82 "\xAE" => '&#174;',
83 "\xAF" => '&#175;',
84 "\xB0" => '&#176;',
85 "\xB1" => '&#177;',
86 "\xB2" => '&#178;',
87 "\xB3" => '&#179;',
88 "\xB4" => '&#180;',
89 "\xB5" => '&#181;',
90 "\xB6" => '&#182;',
91 "\xB7" => '&#183;',
92 "\xB8" => '&#184;',
93 "\xB9" => '&#185;',
94 "\xBA" => '&#186;',
95 "\xBB" => '&#187;',
96 "\xBC" => '&#188;',
97 "\xBD" => '&#189;',
98 "\xBE" => '&#190;',
99 "\xBF" => '&#191;',
100 "\xC0" => '&#192;',
101 "\xC1" => '&#193;',
102 "\xC2" => '&#194;',
103 "\xC3" => '&#195;',
104 "\xC4" => '&#196;',
105 "\xC5" => '&#197;',
106 "\xC6" => '&#198;',
107 "\xC7" => '&#199;',
108 "\xC8" => '&#200;',
109 "\xC9" => '&#201;',
110 "\xCA" => '&#202;',
111 "\xCB" => '&#203;',
112 "\xCC" => '&#204;',
113 "\xCD" => '&#205;',
114 "\xCE" => '&#206;',
115 "\xCF" => '&#207;',
116 "\xD0" => '&#208;',
117 "\xD1" => '&#209;',
118 "\xD2" => '&#210;',
119 "\xD3" => '&#211;',
120 "\xD4" => '&#212;',
121 "\xD5" => '&#213;',
122 "\xD6" => '&#214;',
123 "\xD7" => '&#215;',
124 "\xD8" => '&#216;',
125 "\xD9" => '&#217;',
126 "\xDA" => '&#218;',
127 "\xDB" => '&#219;',
128 "\xDC" => '&#220;',
129 "\xDD" => '&#221;',
130 "\xDE" => '&#222;',
131 "\xDF" => '&#223;',
132 "\xE0" => '&#224;',
133 "\xE1" => '&#225;',
134 "\xE2" => '&#226;',
135 "\xE3" => '&#227;',
136 "\xE4" => '&#228;',
137 "\xE5" => '&#229;',
138 "\xE6" => '&#230;',
139 "\xE7" => '&#231;',
140 "\xE8" => '&#232;',
141 "\xE9" => '&#233;',
142 "\xEA" => '&#234;',
143 "\xEB" => '&#235;',
144 "\xEC" => '&#236;',
145 "\xED" => '&#237;',
146 "\xEE" => '&#238;',
147 "\xEF" => '&#239;',
148 "\xF0" => '&#240;',
149 "\xF1" => '&#241;',
150 "\xF2" => '&#242;',
151 "\xF3" => '&#243;',
152 "\xF4" => '&#244;',
153 "\xF5" => '&#245;',
154 "\xF6" => '&#246;',
155 "\xF7" => '&#247;',
156 "\xF8" => '&#248;',
157 "\xF9" => '&#249;',
158 "\xFA" => '&#250;',
159 "\xFB" => '&#251;',
160 "\xFC" => '&#252;',
161 "\xFD" => '&#253;',
162 "\xFE" => '&#254;',
163 "\xFF" => '&#255;'
164 );
165
166 $string = str_replace(array_keys($cp1252), array_values($cp1252), $string);
167
168 return $string;
169 }
170
171 ?>