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