1f92952d6e6ffa939ef719a6d80d9c4bee09138d
[squirrelmail.git] / functions / decode / cp1255.php
1 <?php
2 /**
3 * decode/cp1255.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 cp1255 decoding function that is needed to read
10 * cp1255 encoded mails in non-cp1255 locale.
11 *
12 * Original data taken from:
13 * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1255.TXT
14 *
15 * Name: cp1255 to Unicode table
16 * Unicode version: 2.0
17 * Table version: 2.01
18 * Table format: Format A
19 * Date: 1/7/2000
20 * Contact: cpxlate@microsoft.com
21 * @package squirrelmail
22 * @subpackage decode
23 */
24
25 /**
26 * Decode cp1255-encoded string
27 * @param string $string Encoded string
28 * @return string $string decoded string
29 */
30 function charset_decode_cp1255 ($string) {
31 global $default_charset;
32
33 if (strtolower($default_charset) == 'windows-1255')
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 $cp1255 = array(
42 "\x80" => '&#8364;',
43 "\x81" => '&#65533;',
44 "\x82" => '&#8218;',
45 "\x83" => '&#402;',
46 "\x84" => '&#8222;',
47 "\x85" => '&#8230;',
48 "\x86" => '&#8224;',
49 "\x87" => '&#8225;',
50 "\x88" => '&#710;',
51 "\x89" => '&#8240;',
52 "\x8A" => '&#65533;',
53 "\x8B" => '&#8249;',
54 "\x8C" => '&#65533;',
55 "\x8D" => '&#65533;',
56 "\x8E" => '&#65533;',
57 "\x8F" => '&#65533;',
58 "\x90" => '&#65533;',
59 "\x91" => '&#8216;',
60 "\x92" => '&#8217;',
61 "\x93" => '&#8220;',
62 "\x94" => '&#8221;',
63 "\x95" => '&#8226;',
64 "\x96" => '&#8211;',
65 "\x97" => '&#8212;',
66 "\x98" => '&#732;',
67 "\x99" => '&#8482;',
68 "\x9A" => '&#65533;',
69 "\x9B" => '&#8250;',
70 "\x9C" => '&#65533;',
71 "\x9D" => '&#65533;',
72 "\x9E" => '&#65533;',
73 "\x9F" => '&#65533;',
74 "\xA0" => '&#160;',
75 "\xA1" => '&#161;',
76 "\xA2" => '&#162;',
77 "\xA3" => '&#163;',
78 "\xA4" => '&#8362;',
79 "\xA5" => '&#165;',
80 "\xA6" => '&#166;',
81 "\xA7" => '&#167;',
82 "\xA8" => '&#168;',
83 "\xA9" => '&#169;',
84 "\xAA" => '&#215;',
85 "\xAB" => '&#171;',
86 "\xAC" => '&#172;',
87 "\xAD" => '&#173;',
88 "\xAE" => '&#174;',
89 "\xAF" => '&#175;',
90 "\xB0" => '&#176;',
91 "\xB1" => '&#177;',
92 "\xB2" => '&#178;',
93 "\xB3" => '&#179;',
94 "\xB4" => '&#180;',
95 "\xB5" => '&#181;',
96 "\xB6" => '&#182;',
97 "\xB7" => '&#183;',
98 "\xB8" => '&#184;',
99 "\xB9" => '&#185;',
100 "\xBA" => '&#247;',
101 "\xBB" => '&#187;',
102 "\xBC" => '&#188;',
103 "\xBD" => '&#189;',
104 "\xBE" => '&#190;',
105 "\xBF" => '&#191;',
106 "\xC0" => '&#1456;',
107 "\xC1" => '&#1457;',
108 "\xC2" => '&#1458;',
109 "\xC3" => '&#1459;',
110 "\xC4" => '&#1460;',
111 "\xC5" => '&#1461;',
112 "\xC6" => '&#1462;',
113 "\xC7" => '&#1463;',
114 "\xC8" => '&#1464;',
115 "\xC9" => '&#1465;',
116 "\xCA" => '&#65533;',
117 "\xCB" => '&#1467;',
118 "\xCC" => '&#1468;',
119 "\xCD" => '&#1469;',
120 "\xCE" => '&#1470;',
121 "\xCF" => '&#1471;',
122 "\xD0" => '&#1472;',
123 "\xD1" => '&#1473;',
124 "\xD2" => '&#1474;',
125 "\xD3" => '&#1475;',
126 "\xD4" => '&#1520;',
127 "\xD5" => '&#1521;',
128 "\xD6" => '&#1522;',
129 "\xD7" => '&#1523;',
130 "\xD8" => '&#1524;',
131 "\xD9" => '&#65533;',
132 "\xDA" => '&#65533;',
133 "\xDB" => '&#65533;',
134 "\xDC" => '&#65533;',
135 "\xDD" => '&#65533;',
136 "\xDE" => '&#65533;',
137 "\xDF" => '&#65533;',
138 "\xE0" => '&#1488;',
139 "\xE1" => '&#1489;',
140 "\xE2" => '&#1490;',
141 "\xE3" => '&#1491;',
142 "\xE4" => '&#1492;',
143 "\xE5" => '&#1493;',
144 "\xE6" => '&#1494;',
145 "\xE7" => '&#1495;',
146 "\xE8" => '&#1496;',
147 "\xE9" => '&#1497;',
148 "\xEA" => '&#1498;',
149 "\xEB" => '&#1499;',
150 "\xEC" => '&#1500;',
151 "\xED" => '&#1501;',
152 "\xEE" => '&#1502;',
153 "\xEF" => '&#1503;',
154 "\xF0" => '&#1504;',
155 "\xF1" => '&#1505;',
156 "\xF2" => '&#1506;',
157 "\xF3" => '&#1507;',
158 "\xF4" => '&#1508;',
159 "\xF5" => '&#1509;',
160 "\xF6" => '&#1510;',
161 "\xF7" => '&#1511;',
162 "\xF8" => '&#1512;',
163 "\xF9" => '&#1513;',
164 "\xFA" => '&#1514;',
165 "\xFB" => '&#65533;',
166 "\xFC" => '&#65533;',
167 "\xFD" => '&#8206;',
168 "\xFE" => '&#8207;',
169 "\xFF" => '&#65533;'
170 );
171
172 $string = str_replace(array_keys($cp1255), array_values($cp1255), $string);
173
174 return $string;
175 }
176
177 ?>