2e288c4efad8c084e63bec9434c4ed6a90fe90d5
[squirrelmail.git] / functions / decode / cp10007.php
1 <?php
2 /*
3 * decode/cp10007.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 cp10007 (MacCyrillic) decoding function that
10 * is needed to read cp10007 encoded mails in non-cp10007 locale.
11 *
12 * Original data taken from:
13 * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/MAC/CYRILLIC.TXT
14 *
15 * Name: cp10007_MacCyrillic 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
25 function charset_decode_cp10007 ($string) {
26 global $default_charset;
27
28 if (strtolower($default_charset) == 'x-mac-cyrillic')
29 return $string;
30
31 /* Only do the slow convert if there are 8-bit characters */
32 /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
33 if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
34 return $string;
35
36 $cp10007 = array(
37 "\x80" => '&#1040;',
38 "\x81" => '&#1041;',
39 "\x82" => '&#1042;',
40 "\x83" => '&#1043;',
41 "\x84" => '&#1044;',
42 "\x85" => '&#1045;',
43 "\x86" => '&#1046;',
44 "\x87" => '&#1047;',
45 "\x88" => '&#1048;',
46 "\x89" => '&#1049;',
47 "\x8A" => '&#1050;',
48 "\x8B" => '&#1051;',
49 "\x8C" => '&#1052;',
50 "\x8D" => '&#1053;',
51 "\x8E" => '&#1054;',
52 "\x8F" => '&#1055;',
53 "\x90" => '&#1056;',
54 "\x91" => '&#1057;',
55 "\x92" => '&#1058;',
56 "\x93" => '&#1059;',
57 "\x94" => '&#1060;',
58 "\x95" => '&#1061;',
59 "\x96" => '&#1062;',
60 "\x97" => '&#1063;',
61 "\x98" => '&#1064;',
62 "\x99" => '&#1065;',
63 "\x9A" => '&#1066;',
64 "\x9B" => '&#1067;',
65 "\x9C" => '&#1068;',
66 "\x9D" => '&#1069;',
67 "\x9E" => '&#1070;',
68 "\x9F" => '&#1071;',
69 "\xA0" => '&#8224;',
70 "\xA1" => '&#176;',
71 "\xA2" => '&#162;',
72 "\xA3" => '&#163;',
73 "\xA4" => '&#167;',
74 "\xA5" => '&#8226;',
75 "\xA6" => '&#182;',
76 "\xA7" => '&#1030;',
77 "\xA8" => '&#174;',
78 "\xA9" => '&#169;',
79 "\xAA" => '&#8482;',
80 "\xAB" => '&#1026;',
81 "\xAC" => '&#1106;',
82 "\xAD" => '&#8800;',
83 "\xAE" => '&#1027;',
84 "\xAF" => '&#1107;',
85 "\xB0" => '&#8734;',
86 "\xB1" => '&#177;',
87 "\xB2" => '&#8804;',
88 "\xB3" => '&#8805;',
89 "\xB4" => '&#1110;',
90 "\xB5" => '&#181;',
91 "\xB6" => '&#8706;',
92 "\xB7" => '&#1032;',
93 "\xB8" => '&#1028;',
94 "\xB9" => '&#1108;',
95 "\xBA" => '&#1031;',
96 "\xBB" => '&#1111;',
97 "\xBC" => '&#1033;',
98 "\xBD" => '&#1113;',
99 "\xBE" => '&#1034;',
100 "\xBF" => '&#1114;',
101 "\xC0" => '&#1112;',
102 "\xC1" => '&#1029;',
103 "\xC2" => '&#172;',
104 "\xC3" => '&#8730;',
105 "\xC4" => '&#402;',
106 "\xC5" => '&#8776;',
107 "\xC6" => '&#8710;',
108 "\xC7" => '&#171;',
109 "\xC8" => '&#187;',
110 "\xC9" => '&#8230;',
111 "\xCA" => '&#160;',
112 "\xCB" => '&#1035;',
113 "\xCC" => '&#1115;',
114 "\xCD" => '&#1036;',
115 "\xCE" => '&#1116;',
116 "\xCF" => '&#1109;',
117 "\xD0" => '&#8211;',
118 "\xD1" => '&#8212;',
119 "\xD2" => '&#8220;',
120 "\xD3" => '&#8221;',
121 "\xD4" => '&#8216;',
122 "\xD5" => '&#8217;',
123 "\xD6" => '&#247;',
124 "\xD7" => '&#8222;',
125 "\xD8" => '&#1038;',
126 "\xD9" => '&#1118;',
127 "\xDA" => '&#1039;',
128 "\xDB" => '&#1119;',
129 "\xDC" => '&#8470;',
130 "\xDD" => '&#1025;',
131 "\xDE" => '&#1105;',
132 "\xDF" => '&#1103;',
133 "\xE0" => '&#1072;',
134 "\xE1" => '&#1073;',
135 "\xE2" => '&#1074;',
136 "\xE3" => '&#1075;',
137 "\xE4" => '&#1076;',
138 "\xE5" => '&#1077;',
139 "\xE6" => '&#1078;',
140 "\xE7" => '&#1079;',
141 "\xE8" => '&#1080;',
142 "\xE9" => '&#1081;',
143 "\xEA" => '&#1082;',
144 "\xEB" => '&#1083;',
145 "\xEC" => '&#1084;',
146 "\xED" => '&#1085;',
147 "\xEE" => '&#1086;',
148 "\xEF" => '&#1087;',
149 "\xF0" => '&#1088;',
150 "\xF1" => '&#1089;',
151 "\xF2" => '&#1090;',
152 "\xF3" => '&#1091;',
153 "\xF4" => '&#1092;',
154 "\xF5" => '&#1093;',
155 "\xF6" => '&#1094;',
156 "\xF7" => '&#1095;',
157 "\xF8" => '&#1096;',
158 "\xF9" => '&#1097;',
159 "\xFA" => '&#1098;',
160 "\xFB" => '&#1099;',
161 "\xFC" => '&#1100;',
162 "\xFD" => '&#1101;',
163 "\xFE" => '&#1102;',
164 "\xFF" => '&#164;'
165 );
166
167 $string = str_replace(array_keys($cp10007), array_values($cp10007), $string);
168
169 return $string;
170 }
171 ?>