Fixed some mistakes.
[squirrelmail.git] / functions / decode / cp1256.php
1 <?php
2 /*
3 * decode/cp1256.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 cp1256 decoding function that is needed to read
10 * cp1256 encoded mails in non-cp1256 locale.
11 *
12 * Original data taken from:
13 * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1256.TXT
14 *
15 * Name: cp1256 to Unicode table
16 * Unicode version: 2.1
17 * Table version: 2.01
18 * Table format: Format A
19 * Date: 01/5/99
20 * Contact: cpxlate@microsoft.com
21 *
22 */
23
24 function charset_decode_cp1256 ($string) {
25 global $default_charset;
26
27 if (strtolower($default_charset) == 'windows-1256')
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 $cp1256 = array(
36 "\x80" => '&#8364;',
37 "\x81" => '&#1662;',
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" => '&#1657;',
47 "\x8B" => '&#8249;',
48 "\x8C" => '&#338;',
49 "\x8D" => '&#1670;',
50 "\x8E" => '&#1688;',
51 "\x8F" => '&#1672;',
52 "\x90" => '&#1711;',
53 "\x91" => '&#8216;',
54 "\x92" => '&#8217;',
55 "\x93" => '&#8220;',
56 "\x94" => '&#8221;',
57 "\x95" => '&#8226;',
58 "\x96" => '&#8211;',
59 "\x97" => '&#8212;',
60 "\x98" => '&#1705;',
61 "\x99" => '&#8482;',
62 "\x9A" => '&#1681;',
63 "\x9B" => '&#8250;',
64 "\x9C" => '&#339;',
65 "\x9D" => '&#8204;',
66 "\x9E" => '&#8205;',
67 "\x9F" => '&#1722;',
68 "\xA0" => '&#160;',
69 "\xA1" => '&#1548;',
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" => '&#1726;',
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" => '&#1563;',
95 "\xBB" => '&#187;',
96 "\xBC" => '&#188;',
97 "\xBD" => '&#189;',
98 "\xBE" => '&#190;',
99 "\xBF" => '&#1567;',
100 "\xC0" => '&#1729;',
101 "\xC1" => '&#1569;',
102 "\xC2" => '&#1570;',
103 "\xC3" => '&#1571;',
104 "\xC4" => '&#1572;',
105 "\xC5" => '&#1573;',
106 "\xC6" => '&#1574;',
107 "\xC7" => '&#1575;',
108 "\xC8" => '&#1576;',
109 "\xC9" => '&#1577;',
110 "\xCA" => '&#1578;',
111 "\xCB" => '&#1579;',
112 "\xCC" => '&#1580;',
113 "\xCD" => '&#1581;',
114 "\xCE" => '&#1582;',
115 "\xCF" => '&#1583;',
116 "\xD0" => '&#1584;',
117 "\xD1" => '&#1585;',
118 "\xD2" => '&#1586;',
119 "\xD3" => '&#1587;',
120 "\xD4" => '&#1588;',
121 "\xD5" => '&#1589;',
122 "\xD6" => '&#1590;',
123 "\xD7" => '&#215;',
124 "\xD8" => '&#1591;',
125 "\xD9" => '&#1592;',
126 "\xDA" => '&#1593;',
127 "\xDB" => '&#1594;',
128 "\xDC" => '&#1600;',
129 "\xDD" => '&#1601;',
130 "\xDE" => '&#1602;',
131 "\xDF" => '&#1603;',
132 "\xE0" => '&#224;',
133 "\xE1" => '&#1604;',
134 "\xE2" => '&#226;',
135 "\xE3" => '&#1605;',
136 "\xE4" => '&#1606;',
137 "\xE5" => '&#1607;',
138 "\xE6" => '&#1608;',
139 "\xE7" => '&#231;',
140 "\xE8" => '&#232;',
141 "\xE9" => '&#233;',
142 "\xEA" => '&#234;',
143 "\xEB" => '&#235;',
144 "\xEC" => '&#1609;',
145 "\xED" => '&#1610;',
146 "\xEE" => '&#238;',
147 "\xEF" => '&#239;',
148 "\xF0" => '&#1611;',
149 "\xF1" => '&#1612;',
150 "\xF2" => '&#1613;',
151 "\xF3" => '&#1614;',
152 "\xF4" => '&#244;',
153 "\xF5" => '&#1615;',
154 "\xF6" => '&#1616;',
155 "\xF7" => '&#247;',
156 "\xF8" => '&#1617;',
157 "\xF9" => '&#249;',
158 "\xFA" => '&#1618;',
159 "\xFB" => '&#251;',
160 "\xFC" => '&#252;',
161 "\xFD" => '&#8206;',
162 "\xFE" => '&#8207;',
163 "\xFF" => '&#1746;'
164 );
165
166 $string = str_replace(array_keys($cp1256), array_values($cp1256), $string);
167
168 return $string;
169 }
170
171 ?>