Phpdocumentor update - sed is your friend for these kinds of things ;)
[squirrelmail.git] / functions / decode / cp1250.php
1 <?php
2 /**
3 * decode/cp1250.php
4 *
5 * Copyright (c) 2003-2004 The SquirrelMail Project Team
6 * Licensed under the GNU GPL. For full terms see the file COPYING.
7 *
8 * This file contains cp1250 decoding function that is needed to read
9 * cp1250 encoded mails in non-cp1250 locale.
10 *
11 * Original data taken from:
12 * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1250.TXT
13 *
14 * Name: cp1250 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
20 *
21 * @version $Id$
22 * @package squirrelmail
23 * @subpackage decode
24 */
25
26 /**
27 * Decode a cp1250 string
28 * @param string $string Encoded string
29 * @return string $string Decoded string
30 */
31 function charset_decode_cp1250 ($string) {
32 global $default_charset;
33
34 if (strtolower($default_charset) == 'windows-1250')
35 return $string;
36
37 /* Only do the slow convert if there are 8-bit characters */
38 /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
39 if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
40 return $string;
41
42 $cp1250 = array(
43 "\x80" => '&#8364;',
44 "\x81" => '&#65533;',
45 "\x82" => '&#8218;',
46 "\x83" => '&#65533;',
47 "\x84" => '&#8222;',
48 "\x85" => '&#8230;',
49 "\x86" => '&#8224;',
50 "\x87" => '&#8225;',
51 "\x88" => '&#65533;',
52 "\x89" => '&#8240;',
53 "\x8A" => '&#352;',
54 "\x8B" => '&#8249;',
55 "\x8C" => '&#346;',
56 "\x8D" => '&#356;',
57 "\x8E" => '&#381;',
58 "\x8F" => '&#377;',
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" => '&#65533;',
68 "\x99" => '&#8482;',
69 "\x9A" => '&#353;',
70 "\x9B" => '&#8250;',
71 "\x9C" => '&#347;',
72 "\x9D" => '&#357;',
73 "\x9E" => '&#382;',
74 "\x9F" => '&#378;',
75 "\xA0" => '&#160;',
76 "\xA1" => '&#711;',
77 "\xA2" => '&#728;',
78 "\xA3" => '&#321;',
79 "\xA4" => '&#164;',
80 "\xA5" => '&#260;',
81 "\xA6" => '&#166;',
82 "\xA7" => '&#167;',
83 "\xA8" => '&#168;',
84 "\xA9" => '&#169;',
85 "\xAA" => '&#350;',
86 "\xAB" => '&#171;',
87 "\xAC" => '&#172;',
88 "\xAD" => '&#173;',
89 "\xAE" => '&#174;',
90 "\xAF" => '&#379;',
91 "\xB0" => '&#176;',
92 "\xB1" => '&#177;',
93 "\xB2" => '&#731;',
94 "\xB3" => '&#322;',
95 "\xB4" => '&#180;',
96 "\xB5" => '&#181;',
97 "\xB6" => '&#182;',
98 "\xB7" => '&#183;',
99 "\xB8" => '&#184;',
100 "\xB9" => '&#261;',
101 "\xBA" => '&#351;',
102 "\xBB" => '&#187;',
103 "\xBC" => '&#317;',
104 "\xBD" => '&#733;',
105 "\xBE" => '&#318;',
106 "\xBF" => '&#380;',
107 "\xC0" => '&#340;',
108 "\xC1" => '&#193;',
109 "\xC2" => '&#194;',
110 "\xC3" => '&#258;',
111 "\xC4" => '&#196;',
112 "\xC5" => '&#313;',
113 "\xC6" => '&#262;',
114 "\xC7" => '&#199;',
115 "\xC8" => '&#268;',
116 "\xC9" => '&#201;',
117 "\xCA" => '&#280;',
118 "\xCB" => '&#203;',
119 "\xCC" => '&#282;',
120 "\xCD" => '&#205;',
121 "\xCE" => '&#206;',
122 "\xCF" => '&#270;',
123 "\xD0" => '&#272;',
124 "\xD1" => '&#323;',
125 "\xD2" => '&#327;',
126 "\xD3" => '&#211;',
127 "\xD4" => '&#212;',
128 "\xD5" => '&#336;',
129 "\xD6" => '&#214;',
130 "\xD7" => '&#215;',
131 "\xD8" => '&#344;',
132 "\xD9" => '&#366;',
133 "\xDA" => '&#218;',
134 "\xDB" => '&#368;',
135 "\xDC" => '&#220;',
136 "\xDD" => '&#221;',
137 "\xDE" => '&#354;',
138 "\xDF" => '&#223;',
139 "\xE0" => '&#341;',
140 "\xE1" => '&#225;',
141 "\xE2" => '&#226;',
142 "\xE3" => '&#259;',
143 "\xE4" => '&#228;',
144 "\xE5" => '&#314;',
145 "\xE6" => '&#263;',
146 "\xE7" => '&#231;',
147 "\xE8" => '&#269;',
148 "\xE9" => '&#233;',
149 "\xEA" => '&#281;',
150 "\xEB" => '&#235;',
151 "\xEC" => '&#283;',
152 "\xED" => '&#237;',
153 "\xEE" => '&#238;',
154 "\xEF" => '&#271;',
155 "\xF0" => '&#273;',
156 "\xF1" => '&#324;',
157 "\xF2" => '&#328;',
158 "\xF3" => '&#243;',
159 "\xF4" => '&#244;',
160 "\xF5" => '&#337;',
161 "\xF6" => '&#246;',
162 "\xF7" => '&#247;',
163 "\xF8" => '&#345;',
164 "\xF9" => '&#367;',
165 "\xFA" => '&#250;',
166 "\xFB" => '&#369;',
167 "\xFC" => '&#252;',
168 "\xFD" => '&#253;',
169 "\xFE" => '&#355;',
170 "\xFF" => '&#729;'
171 );
172
173 $string = str_replace(array_keys($cp1250), array_values($cp1250), $string);
174
175 return $string;
176 }
177
178 ?>