adding address book block
[squirrelmail.git] / functions / decode / cp1252.php
CommitLineData
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
32function charset_decode_cp1252 ($string) {
33 global $default_charset;
34
35 if (strtolower($default_charset) == 'windows-1252')
36 return $string;
37
e53c9681 38 // don't do decoding when there are no 8bit symbols
39 if (! sq_is8bit($string,'windows-1252'))
211d912f 40 return $string;
41
42 $cp1252 = array(
43 "\x80" => '&#8364;',
44 "\x81" => '&#65533;',
45 "\x82" => '&#8218;',
46 "\x83" => '&#402;',
47 "\x84" => '&#8222;',
48 "\x85" => '&#8230;',
49 "\x86" => '&#8224;',
50 "\x87" => '&#8225;',
51 "\x88" => '&#710;',
52 "\x89" => '&#8240;',
53 "\x8A" => '&#352;',
54 "\x8B" => '&#8249;',
55 "\x8C" => '&#338;',
56 "\x8D" => '&#65533;',
57 "\x8E" => '&#381;',
58 "\x8F" => '&#65533;',
59 "\x90" => '&#65533;',
60 "\x91" => '&#8216;',
61 "\x92" => '&#8217;',
62 "\x93" => '&#8220;',
63 "\x94" => '&#8221;',
64 "\x95" => '&#8226;',
65 "\x96" => '&#8211;',
66 "\x97" => '&#8212;',
67 "\x98" => '&#732;',
68 "\x99" => '&#8482;',
69 "\x9A" => '&#353;',
70 "\x9B" => '&#8250;',
71 "\x9C" => '&#339;',
72 "\x9D" => '&#65533;',
73 "\x9E" => '&#382;',
74 "\x9F" => '&#376;',
75 "\xA0" => '&#160;',
76 "\xA1" => '&#161;',
77 "\xA2" => '&#162;',
78 "\xA3" => '&#163;',
79 "\xA4" => '&#164;',
80 "\xA5" => '&#165;',
81 "\xA6" => '&#166;',
82 "\xA7" => '&#167;',
83 "\xA8" => '&#168;',
84 "\xA9" => '&#169;',
85 "\xAA" => '&#170;',
86 "\xAB" => '&#171;',
87 "\xAC" => '&#172;',
88 "\xAD" => '&#173;',
89 "\xAE" => '&#174;',
90 "\xAF" => '&#175;',
91 "\xB0" => '&#176;',
92 "\xB1" => '&#177;',
93 "\xB2" => '&#178;',
94 "\xB3" => '&#179;',
95 "\xB4" => '&#180;',
96 "\xB5" => '&#181;',
97 "\xB6" => '&#182;',
98 "\xB7" => '&#183;',
99 "\xB8" => '&#184;',
100 "\xB9" => '&#185;',
101 "\xBA" => '&#186;',
102 "\xBB" => '&#187;',
103 "\xBC" => '&#188;',
104 "\xBD" => '&#189;',
105 "\xBE" => '&#190;',
106 "\xBF" => '&#191;',
107 "\xC0" => '&#192;',
108 "\xC1" => '&#193;',
109 "\xC2" => '&#194;',
110 "\xC3" => '&#195;',
111 "\xC4" => '&#196;',
112 "\xC5" => '&#197;',
113 "\xC6" => '&#198;',
114 "\xC7" => '&#199;',
115 "\xC8" => '&#200;',
116 "\xC9" => '&#201;',
117 "\xCA" => '&#202;',
118 "\xCB" => '&#203;',
119 "\xCC" => '&#204;',
120 "\xCD" => '&#205;',
121 "\xCE" => '&#206;',
122 "\xCF" => '&#207;',
123 "\xD0" => '&#208;',
124 "\xD1" => '&#209;',
125 "\xD2" => '&#210;',
126 "\xD3" => '&#211;',
127 "\xD4" => '&#212;',
128 "\xD5" => '&#213;',
129 "\xD6" => '&#214;',
130 "\xD7" => '&#215;',
131 "\xD8" => '&#216;',
132 "\xD9" => '&#217;',
133 "\xDA" => '&#218;',
134 "\xDB" => '&#219;',
135 "\xDC" => '&#220;',
136 "\xDD" => '&#221;',
137 "\xDE" => '&#222;',
138 "\xDF" => '&#223;',
139 "\xE0" => '&#224;',
140 "\xE1" => '&#225;',
141 "\xE2" => '&#226;',
142 "\xE3" => '&#227;',
143 "\xE4" => '&#228;',
144 "\xE5" => '&#229;',
145 "\xE6" => '&#230;',
146 "\xE7" => '&#231;',
147 "\xE8" => '&#232;',
148 "\xE9" => '&#233;',
149 "\xEA" => '&#234;',
150 "\xEB" => '&#235;',
151 "\xEC" => '&#236;',
152 "\xED" => '&#237;',
153 "\xEE" => '&#238;',
154 "\xEF" => '&#239;',
155 "\xF0" => '&#240;',
156 "\xF1" => '&#241;',
157 "\xF2" => '&#242;',
158 "\xF3" => '&#243;',
159 "\xF4" => '&#244;',
160 "\xF5" => '&#245;',
161 "\xF6" => '&#246;',
162 "\xF7" => '&#247;',
163 "\xF8" => '&#248;',
164 "\xF9" => '&#249;',
165 "\xFA" => '&#250;',
166 "\xFB" => '&#251;',
167 "\xFC" => '&#252;',
168 "\xFD" => '&#253;',
169 "\xFE" => '&#254;',
170 "\xFF" => '&#255;'
171 );
172
173 $string = str_replace(array_keys($cp1252), array_values($cp1252), $string);
174
175 return $string;
176}
177
d6c32258 178?>