Adding decoding support for two DOSCyr charsets and several x-mac-* charsets.
[squirrelmail.git] / functions / decode / cp10000.php
1 <?php
2 /*
3 * decode/cp10000.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 cp10000 (MacRoman) decoding function that
10 * is needed to read cp10000 encoded mails in non-cp10000 locale.
11 *
12 * Original data taken from:
13 * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/MAC/ROMAN.TXT
14 *
15 * Name: cp10000_MacRoman to Unicode table
16 * Unicode version: 2.0
17 * Table version: 2.00
18 * Table format: Format A
19 * Date: 04/24/96
20 * Authors: Lori Brownell <loribr@microsoft.com>
21 * K.D. Chang <a-kchang@microsoft.com>
22 */
23
24 function charset_decode_cp10000 ($string) {
25 global $default_charset;
26
27 if (strtolower($default_charset) == 'x-mac-roman')
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 $cp10000 = array(
36 "\0x80" => '&#196;',
37 "\0x81" => '&#197;',
38 "\0x82" => '&#199;',
39 "\0x83" => '&#201;',
40 "\0x84" => '&#209;',
41 "\0x85" => '&#214;',
42 "\0x86" => '&#220;',
43 "\0x87" => '&#225;',
44 "\0x88" => '&#224;',
45 "\0x89" => '&#226;',
46 "\0x8A" => '&#228;',
47 "\0x8B" => '&#227;',
48 "\0x8C" => '&#229;',
49 "\0x8D" => '&#231;',
50 "\0x8E" => '&#233;',
51 "\0x8F" => '&#232;',
52 "\0x90" => '&#234;',
53 "\0x91" => '&#235;',
54 "\0x92" => '&#237;',
55 "\0x93" => '&#236;',
56 "\0x94" => '&#238;',
57 "\0x95" => '&#239;',
58 "\0x96" => '&#241;',
59 "\0x97" => '&#243;',
60 "\0x98" => '&#242;',
61 "\0x99" => '&#244;',
62 "\0x9A" => '&#246;',
63 "\0x9B" => '&#245;',
64 "\0x9C" => '&#250;',
65 "\0x9D" => '&#249;',
66 "\0x9E" => '&#251;',
67 "\0x9F" => '&#252;',
68 "\0xA0" => '&#8224;',
69 "\0xA1" => '&#176;',
70 "\0xA2" => '&#162;',
71 "\0xA3" => '&#163;',
72 "\0xA4" => '&#167;',
73 "\0xA5" => '&#8226;',
74 "\0xA6" => '&#182;',
75 "\0xA7" => '&#223;',
76 "\0xA8" => '&#174;',
77 "\0xA9" => '&#169;',
78 "\0xAA" => '&#8482;',
79 "\0xAB" => '&#180;',
80 "\0xAC" => '&#168;',
81 "\0xAD" => '&#8800;',
82 "\0xAE" => '&#198;',
83 "\0xAF" => '&#216;',
84 "\0xB0" => '&#8734;',
85 "\0xB1" => '&#177;',
86 "\0xB2" => '&#8804;',
87 "\0xB3" => '&#8805;',
88 "\0xB4" => '&#165;',
89 "\0xB5" => '&#181;',
90 "\0xB6" => '&#8706;',
91 "\0xB7" => '&#8721;',
92 "\0xB8" => '&#8719;',
93 "\0xB9" => '&#960;',
94 "\0xBA" => '&#8747;',
95 "\0xBB" => '&#170;',
96 "\0xBC" => '&#186;',
97 "\0xBD" => '&#8486;',
98 "\0xBE" => '&#230;',
99 "\0xBF" => '&#248;',
100 "\0xC0" => '&#191;',
101 "\0xC1" => '&#161;',
102 "\0xC2" => '&#172;',
103 "\0xC3" => '&#8730;',
104 "\0xC4" => '&#402;',
105 "\0xC5" => '&#8776;',
106 "\0xC6" => '&#8710;',
107 "\0xC7" => '&#171;',
108 "\0xC8" => '&#187;',
109 "\0xC9" => '&#8230;',
110 "\0xCA" => '&#160;',
111 "\0xCB" => '&#192;',
112 "\0xCC" => '&#195;',
113 "\0xCD" => '&#213;',
114 "\0xCE" => '&#338;',
115 "\0xCF" => '&#339;',
116 "\0xD0" => '&#8211;',
117 "\0xD1" => '&#8212;',
118 "\0xD2" => '&#8220;',
119 "\0xD3" => '&#8221;',
120 "\0xD4" => '&#8216;',
121 "\0xD5" => '&#8217;',
122 "\0xD6" => '&#247;',
123 "\0xD7" => '&#9674;',
124 "\0xD8" => '&#255;',
125 "\0xD9" => '&#376;',
126 "\0xDA" => '&#8260;',
127 "\0xDB" => '&#164;',
128 "\0xDC" => '&#8249;',
129 "\0xDD" => '&#8250;',
130 "\0xDE" => '&#64257;',
131 "\0xDF" => '&#64258;',
132 "\0xE0" => '&#8225;',
133 "\0xE1" => '&#183;',
134 "\0xE2" => '&#8218;',
135 "\0xE3" => '&#8222;',
136 "\0xE4" => '&#8240;',
137 "\0xE5" => '&#194;',
138 "\0xE6" => '&#202;',
139 "\0xE7" => '&#193;',
140 "\0xE8" => '&#203;',
141 "\0xE9" => '&#200;',
142 "\0xEA" => '&#205;',
143 "\0xEB" => '&#206;',
144 "\0xEC" => '&#207;',
145 "\0xED" => '&#204;',
146 "\0xEE" => '&#211;',
147 "\0xEF" => '&#212;',
148 "\0xF0" => '&#65535;',
149 "\0xF1" => '&#210;',
150 "\0xF2" => '&#218;',
151 "\0xF3" => '&#219;',
152 "\0xF4" => '&#217;',
153 "\0xF5" => '&#305;',
154 "\0xF6" => '&#710;',
155 "\0xF7" => '&#732;',
156 "\0xF8" => '&#175;',
157 "\0xF9" => '&#728;',
158 "\0xFA" => '&#729;',
159 "\0xFB" => '&#730;',
160 "\0xFC" => '&#184;',
161 "\0xFD" => '&#733;',
162 "\0xFE" => '&#731;',
163 "\0xFF" => '&#711;'
164 );
165
166 $string = str_replace(array_keys($cp10000), array_values($cp10000), $string);
167
168 return $string;
169 }
170 ?>