Adding decoding support for two DOSCyr charsets and several x-mac-* charsets.
[squirrelmail.git] / functions / decode / cp10029.php
CommitLineData
e9a71964 1<?php
2/*
3 * decode/cp10029.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 cp10029 (MacLatin2) decoding function that
10 * is needed to read cp10029 encoded mails in non-cp10029 locale.
11 *
12 * Original data taken from:
13 * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/MAC/LATIN2.TXT
14 *
15 * Name: cp10029_MacLatin2 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
24function charset_decode_cp10029 ($string) {
25 global $default_charset;
26
27 if (strtolower($default_charset) == 'x-mac-centraleurroman')
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 $cp10029 = array(
36 "\0x80" => '&#196;',
37 "\0x81" => '&#256;',
38 "\0x82" => '&#257;',
39 "\0x83" => '&#201;',
40 "\0x84" => '&#260;',
41 "\0x85" => '&#214;',
42 "\0x86" => '&#220;',
43 "\0x87" => '&#225;',
44 "\0x88" => '&#261;',
45 "\0x89" => '&#268;',
46 "\0x8A" => '&#228;',
47 "\0x8B" => '&#269;',
48 "\0x8C" => '&#262;',
49 "\0x8D" => '&#263;',
50 "\0x8E" => '&#233;',
51 "\0x8F" => '&#377;',
52 "\0x90" => '&#378;',
53 "\0x91" => '&#270;',
54 "\0x92" => '&#237;',
55 "\0x93" => '&#271;',
56 "\0x94" => '&#274;',
57 "\0x95" => '&#275;',
58 "\0x96" => '&#278;',
59 "\0x97" => '&#243;',
60 "\0x98" => '&#279;',
61 "\0x99" => '&#244;',
62 "\0x9A" => '&#246;',
63 "\0x9B" => '&#245;',
64 "\0x9C" => '&#250;',
65 "\0x9D" => '&#282;',
66 "\0x9E" => '&#283;',
67 "\0x9F" => '&#252;',
68 "\0xA0" => '&#8224;',
69 "\0xA1" => '&#176;',
70 "\0xA2" => '&#280;',
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" => '&#281;',
80 "\0xAC" => '&#168;',
81 "\0xAD" => '&#8800;',
82 "\0xAE" => '&#291;',
83 "\0xAF" => '&#302;',
84 "\0xB0" => '&#303;',
85 "\0xB1" => '&#298;',
86 "\0xB2" => '&#8804;',
87 "\0xB3" => '&#8805;',
88 "\0xB4" => '&#299;',
89 "\0xB5" => '&#310;',
90 "\0xB6" => '&#8706;',
91 "\0xB7" => '&#8721;',
92 "\0xB8" => '&#322;',
93 "\0xB9" => '&#315;',
94 "\0xBA" => '&#316;',
95 "\0xBB" => '&#317;',
96 "\0xBC" => '&#318;',
97 "\0xBD" => '&#313;',
98 "\0xBE" => '&#314;',
99 "\0xBF" => '&#325;',
100 "\0xC0" => '&#326;',
101 "\0xC1" => '&#323;',
102 "\0xC2" => '&#172;',
103 "\0xC3" => '&#8730;',
104 "\0xC4" => '&#324;',
105 "\0xC5" => '&#327;',
106 "\0xC6" => '&#8710;',
107 "\0xC7" => '&#171;',
108 "\0xC8" => '&#187;',
109 "\0xC9" => '&#8230;',
110 "\0xCA" => '&#160;',
111 "\0xCB" => '&#328;',
112 "\0xCC" => '&#336;',
113 "\0xCD" => '&#213;',
114 "\0xCE" => '&#337;',
115 "\0xCF" => '&#332;',
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" => '&#333;',
125 "\0xD9" => '&#340;',
126 "\0xDA" => '&#341;',
127 "\0xDB" => '&#344;',
128 "\0xDC" => '&#8249;',
129 "\0xDD" => '&#8250;',
130 "\0xDE" => '&#345;',
131 "\0xDF" => '&#342;',
132 "\0xE0" => '&#343;',
133 "\0xE1" => '&#352;',
134 "\0xE2" => '&#8218;',
135 "\0xE3" => '&#8222;',
136 "\0xE4" => '&#353;',
137 "\0xE5" => '&#346;',
138 "\0xE6" => '&#347;',
139 "\0xE7" => '&#193;',
140 "\0xE8" => '&#356;',
141 "\0xE9" => '&#357;',
142 "\0xEA" => '&#205;',
143 "\0xEB" => '&#381;',
144 "\0xEC" => '&#382;',
145 "\0xED" => '&#362;',
146 "\0xEE" => '&#211;',
147 "\0xEF" => '&#212;',
148 "\0xF0" => '&#363;',
149 "\0xF1" => '&#366;',
150 "\0xF2" => '&#218;',
151 "\0xF3" => '&#367;',
152 "\0xF4" => '&#368;',
153 "\0xF5" => '&#369;',
154 "\0xF6" => '&#370;',
155 "\0xF7" => '&#371;',
156 "\0xF8" => '&#221;',
157 "\0xF9" => '&#253;',
158 "\0xFA" => '&#311;',
159 "\0xFB" => '&#379;',
160 "\0xFC" => '&#321;',
161 "\0xFD" => '&#380;',
162 "\0xFE" => '&#290;',
163 "\0xFF" => '&#711;'
164 );
165
166 $string = str_replace(array_keys($cp10029), array_values($cp10029), $string);
167
168 return $string;
169}
170?>