extra quote removed
[squirrelmail.git] / functions / decode / cp1255.php
CommitLineData
211d912f 1<?php
d6c32258 2/**
211d912f 3 * decode/cp1255.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 cp1255 decoding function that is needed to read
9 * cp1255 encoded mails in non-cp1255 locale.
10 *
11 * Original data taken from:
12 * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1255.TXT
13 *
14 * Name: cp1255 to Unicode table
15 * Unicode version: 2.0
16 * Table version: 2.01
17 * Table format: Format A
18 * Date: 1/7/2000
19 * Contact: cpxlate@microsoft.com
31841a9e 20 *
21 * @version $Id$
d6c32258 22 * @package squirrelmail
23 * @subpackage decode
211d912f 24 */
25
d6c32258 26/**
27 * Decode cp1255-encoded string
28 * @param string $string Encoded string
29 * @return string $string decoded string
30 */
211d912f 31function charset_decode_cp1255 ($string) {
32 global $default_charset;
33
34 if (strtolower($default_charset) == 'windows-1255')
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 $cp1255 = 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" => '&#65533;',
54 "\x8B" => '&#8249;',
55 "\x8C" => '&#65533;',
56 "\x8D" => '&#65533;',
57 "\x8E" => '&#65533;',
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" => '&#65533;',
70 "\x9B" => '&#8250;',
71 "\x9C" => '&#65533;',
72 "\x9D" => '&#65533;',
73 "\x9E" => '&#65533;',
74 "\x9F" => '&#65533;',
75 "\xA0" => '&#160;',
76 "\xA1" => '&#161;',
77 "\xA2" => '&#162;',
78 "\xA3" => '&#163;',
79 "\xA4" => '&#8362;',
80 "\xA5" => '&#165;',
81 "\xA6" => '&#166;',
82 "\xA7" => '&#167;',
83 "\xA8" => '&#168;',
84 "\xA9" => '&#169;',
85 "\xAA" => '&#215;',
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" => '&#247;',
102 "\xBB" => '&#187;',
103 "\xBC" => '&#188;',
104 "\xBD" => '&#189;',
105 "\xBE" => '&#190;',
106 "\xBF" => '&#191;',
107 "\xC0" => '&#1456;',
108 "\xC1" => '&#1457;',
109 "\xC2" => '&#1458;',
110 "\xC3" => '&#1459;',
111 "\xC4" => '&#1460;',
112 "\xC5" => '&#1461;',
113 "\xC6" => '&#1462;',
114 "\xC7" => '&#1463;',
115 "\xC8" => '&#1464;',
116 "\xC9" => '&#1465;',
117 "\xCA" => '&#65533;',
118 "\xCB" => '&#1467;',
119 "\xCC" => '&#1468;',
120 "\xCD" => '&#1469;',
121 "\xCE" => '&#1470;',
122 "\xCF" => '&#1471;',
123 "\xD0" => '&#1472;',
124 "\xD1" => '&#1473;',
125 "\xD2" => '&#1474;',
126 "\xD3" => '&#1475;',
127 "\xD4" => '&#1520;',
128 "\xD5" => '&#1521;',
129 "\xD6" => '&#1522;',
130 "\xD7" => '&#1523;',
131 "\xD8" => '&#1524;',
132 "\xD9" => '&#65533;',
133 "\xDA" => '&#65533;',
134 "\xDB" => '&#65533;',
135 "\xDC" => '&#65533;',
136 "\xDD" => '&#65533;',
137 "\xDE" => '&#65533;',
138 "\xDF" => '&#65533;',
139 "\xE0" => '&#1488;',
140 "\xE1" => '&#1489;',
141 "\xE2" => '&#1490;',
142 "\xE3" => '&#1491;',
143 "\xE4" => '&#1492;',
144 "\xE5" => '&#1493;',
145 "\xE6" => '&#1494;',
146 "\xE7" => '&#1495;',
147 "\xE8" => '&#1496;',
148 "\xE9" => '&#1497;',
149 "\xEA" => '&#1498;',
150 "\xEB" => '&#1499;',
151 "\xEC" => '&#1500;',
152 "\xED" => '&#1501;',
153 "\xEE" => '&#1502;',
154 "\xEF" => '&#1503;',
155 "\xF0" => '&#1504;',
156 "\xF1" => '&#1505;',
157 "\xF2" => '&#1506;',
158 "\xF3" => '&#1507;',
159 "\xF4" => '&#1508;',
160 "\xF5" => '&#1509;',
161 "\xF6" => '&#1510;',
162 "\xF7" => '&#1511;',
163 "\xF8" => '&#1512;',
164 "\xF9" => '&#1513;',
165 "\xFA" => '&#1514;',
166 "\xFB" => '&#65533;',
167 "\xFC" => '&#65533;',
168 "\xFD" => '&#8206;',
169 "\xFE" => '&#8207;',
170 "\xFF" => '&#65533;'
171 );
172
173 $string = str_replace(array_keys($cp1255), array_values($cp1255), $string);
174
175 return $string;
176}
177
d6c32258 178?>