* My last color was a smidge too bright.
[squirrelmail.git] / functions / i18n.php
CommitLineData
59177427 1<?php
1fd97780 2
3/**
4 ** i18n.php
5 **
6 ** This file contains variuos functions that are needed to do
7 ** internationalization of SquirrelMail.
8 **
c1d54dc7 9 ** Internally the output character set is used. Other characters are
10 ** encoded using Unicode entities according to HTML 4.0.
173ed887 11 **
b8c4285a 12 ** $Id$
1fd97780 13 **/
14
15 $i18n_php = true;
066c374f 16 if (! isset($squirrelmail_language)) { $squirrelmail_language = ''; }
1fd97780 17
d30d79f2 18 // This array specifies the available languages.
066c374f 19 $languages['en']['NAME'] = 'English';
20 $languages['en']['CHARSET'] = 'iso-8859-1';
13e0c649 21
066c374f 22 $languages['ca']['NAME'] = 'Catalan';
23 $languages['ca']['CHARSET'] = 'iso-8859-1';
13e0c649 24
066c374f 25 $languages['cs_CZ']['NAME'] = 'Czech';
26 $languages['cs_CZ']['CHARSET'] = 'iso-8859-2';
13e0c649 27
066c374f 28 $languages['da']['NAME'] = 'Danish';
29 $languages['da']['CHARSET'] = 'iso-8859-1';
13e0c649 30
066c374f 31 $languages['de']['NAME'] = 'Deutsch';
32 $languages['de']['CHARSET'] = 'iso-8859-1';
13e0c649 33
066c374f 34 $languages['nl']['NAME'] = 'Dutch';
35 $languages['nl']['CHARSET'] = 'iso-8859-1';
13e0c649 36
066c374f 37 $languages['fr']['NAME'] = 'French';
38 $languages['fr']['CHARSET'] = 'iso-8859-1';
13e0c649 39
066c374f 40 $languages['fi']['NAME'] = 'Finnish';
41 $languages['fi']['CHARSET'] = 'iso-8859-1';
42
d546b253 43 $languages['hu']['NAME'] = 'Hungarian';
44 $languages['hu']['CHARSET'] = 'iso-8859-1';
45
8b7f3fe5 46 $languages['is']['NAME'] = 'Icelandic';
47 $languages['is']['CHARSET'] = 'iso-8859-1';
48
066c374f 49 $languages['it']['NAME'] = 'Italian';
50 $languages['it']['CHARSET'] = 'iso-8859-1';
51
52 $languages['ko']['NAME'] = 'Korean';
53 $languages['ko']['CHARSET'] = 'euc-KR';
13e0c649 54
066c374f 55 $languages['no']['NAME'] = 'Norwegian (Bokm&aring;l)';
56 $languages['no']['CHARSET'] = 'iso-8859-1';
13e0c649 57
066c374f 58 $languages['no_NO_ny']['NAME'] = 'Norwegian (Nynorsk)';
59 $languages['no_NO_ny']['CHARSET'] = 'iso-8859-1';
13e0c649 60
066c374f 61 $languages['pl']['NAME'] = 'Polish';
62 $languages['pl']['CHARSET'] = 'iso-8859-2';
13e0c649 63
066c374f 64 $languages['pt_BR']['NAME'] = 'Portuguese (Brazil)';
65 $languages['pt_BR']['CHARSET'] = 'iso-8859-1';
13e0c649 66
066c374f 67 $languages['ru']['NAME'] = 'Russian KOI8-R';
68 $languages['ru']['CHARSET'] = 'koi8-r';
13e0c649 69
066c374f 70 $languages['sr']['NAME'] = 'Serbian';
71 $languages['sr']['CHARSET'] = 'iso-8859-2';
13e0c649 72
066c374f 73 $languages['es']['NAME'] = 'Spanish';
74 $languages['es']['CHARSET'] = 'iso-8859-1';
75
76 $languages['sv']['NAME'] = 'Swedish';
77 $languages['sv']['CHARSET'] = 'iso-8859-1';
13e0c649 78
066c374f 79 $languages['tw']['NAME'] = 'Taiwan';
80 $languages['tw']['CHARSET'] = 'big5';
13e0c649 81
d30d79f2 82
1fd97780 83 // Decodes a string to the internal encoding from the given charset
84 function charset_decode ($charset, $string) {
e4a256af 85 global $debug_mime;
86
1fd97780 87 // All HTML special characters are 7 bit and can be replaced first
88 $string = htmlspecialchars ($string);
89
44139266 90 $charset = strtolower($charset);
1fd97780 91
066c374f 92 if ($debug_mime) $string = $charset . ':' . $string;
e4a256af 93
066c374f 94 if (ereg('iso-8859-([[:digit:]]+)', $charset, $res)) {
95 if ($res[1] == '1')
1fd97780 96 return charset_decode_iso_8859_1 ($string);
066c374f 97 else if ($res[1] == '2')
a89c13f5 98 return charset_decode_iso_8859_2 ($string);
066c374f 99 else if ($res[1] == '7')
173ed887 100 return charset_decode_iso_8859_7 ($string);
066c374f 101 else if ($res[1] == '15')
1fd97780 102 return charset_decode_iso_8859_15 ($string);
103 else
104 return charset_decode_iso_8859_default ($string);
066c374f 105 } else if ($charset == 'ns_4551-1') {
1fd97780 106 return charset_decode_ns_4551_1 ($string);
066c374f 107 } else if ($charset == 'koi8-r') {
17ce8467 108 return charset_decode_koi8r ($string);
209e2f82 109 } else
066c374f 110 return $string;
1fd97780 111 }
112
113 // iso-8859-1 is the same as Latin 1 and is normally used
114 // in western europe.
115 function charset_decode_iso_8859_1 ($string) {
04563822 116 global $default_charset;
1fd97780 117
066c374f 118 if (strtolower($default_charset) == 'iso-8859-1') {
04563822 119 return $string;
120 } else {
121 // Only do the slow convert if there are 8-bit characters
122 if (ereg("[\200-\377]", $string)) {
066c374f 123 $string = str_replace("\201", '&#129;', $string);
124 $string = str_replace("\202", '&#130;', $string);
125 $string = str_replace("\203", '&#131;', $string);
126 $string = str_replace("\204", '&#132;', $string);
127 $string = str_replace("\205", '&#133;', $string);
128 $string = str_replace("\206", '&#134;', $string);
129 $string = str_replace("\207", '&#135;', $string);
130 $string = str_replace("\210", '&#136;', $string);
131 $string = str_replace("\211", '&#137;', $string);
132 $string = str_replace("\212", '&#138;', $string);
133 $string = str_replace("\213", '&#139;', $string);
134 $string = str_replace("\214", '&#140;', $string);
135 $string = str_replace("\215", '&#141;', $string);
136 $string = str_replace("\216", '&#142;', $string);
137 $string = str_replace("\217", '&#143;', $string);
138 $string = str_replace("\220", '&#144;', $string);
139 $string = str_replace("\221", '&#145;', $string);
140 $string = str_replace("\222", '&#146;', $string);
141 $string = str_replace("\223", '&#147;', $string);
142 $string = str_replace("\224", '&#148;', $string);
143 $string = str_replace("\225", '&#149;', $string);
144 $string = str_replace("\226", '&#150;', $string);
145 $string = str_replace("\227", '&#151;', $string);
146 $string = str_replace("\230", '&#152;', $string);
147 $string = str_replace("\231", '&#153;', $string);
148 $string = str_replace("\232", '&#154;', $string);
149 $string = str_replace("\233", '&#155;', $string);
150 $string = str_replace("\234", '&#156;', $string);
151 $string = str_replace("\235", '&#157;', $string);
152 $string = str_replace("\236", '&#158;', $string);
153 $string = str_replace("\237", '&#159;', $string);
154 $string = str_replace("\240", '&#160;', $string);
155 $string = str_replace("\241", '&#161;', $string);
156 $string = str_replace("\242", '&#162;', $string);
157 $string = str_replace("\243", '&#163;', $string);
158 $string = str_replace("\244", '&#164;', $string);
159 $string = str_replace("\245", '&#165;', $string);
160 $string = str_replace("\246", '&#166;', $string);
161 $string = str_replace("\247", '&#167;', $string);
162 $string = str_replace("\250", '&#168;', $string);
163 $string = str_replace("\251", '&#169;', $string);
164 $string = str_replace("\252", '&#170;', $string);
165 $string = str_replace("\253", '&#171;', $string);
166 $string = str_replace("\254", '&#172;', $string);
167 $string = str_replace("\255", '&#173;', $string);
168 $string = str_replace("\256", '&#174;', $string);
169 $string = str_replace("\257", '&#175;', $string);
170 $string = str_replace("\260", '&#176;', $string);
171 $string = str_replace("\261", '&#177;', $string);
172 $string = str_replace("\262", '&#178;', $string);
173 $string = str_replace("\263", '&#179;', $string);
174 $string = str_replace("\264", '&#180;', $string);
175 $string = str_replace("\265", '&#181;', $string);
176 $string = str_replace("\266", '&#182;', $string);
177 $string = str_replace("\267", '&#183;', $string);
178 $string = str_replace("\270", '&#184;', $string);
179 $string = str_replace("\271", '&#185;', $string);
180 $string = str_replace("\272", '&#186;', $string);
181 $string = str_replace("\273", '&#187;', $string);
182 $string = str_replace("\274", '&#188;', $string);
183 $string = str_replace("\275", '&#189;', $string);
184 $string = str_replace("\276", '&#190;', $string);
185 $string = str_replace("\277", '&#191;', $string);
186 $string = str_replace("\300", '&#192;', $string);
187 $string = str_replace("\301", '&#193;', $string);
188 $string = str_replace("\302", '&#194;', $string);
189 $string = str_replace("\303", '&#195;', $string);
190 $string = str_replace("\304", '&#196;', $string);
191 $string = str_replace("\305", '&#197;', $string);
192 $string = str_replace("\306", '&#198;', $string);
193 $string = str_replace("\307", '&#199;', $string);
194 $string = str_replace("\310", '&#200;', $string);
195 $string = str_replace("\311", '&#201;', $string);
196 $string = str_replace("\312", '&#202;', $string);
197 $string = str_replace("\313", '&#203;', $string);
198 $string = str_replace("\314", '&#204;', $string);
199 $string = str_replace("\315", '&#205;', $string);
200 $string = str_replace("\316", '&#206;', $string);
201 $string = str_replace("\317", '&#207;', $string);
202 $string = str_replace("\320", '&#208;', $string);
203 $string = str_replace("\321", '&#209;', $string);
204 $string = str_replace("\322", '&#210;', $string);
205 $string = str_replace("\323", '&#211;', $string);
206 $string = str_replace("\324", '&#212;', $string);
207 $string = str_replace("\325", '&#213;', $string);
208 $string = str_replace("\326", '&#214;', $string);
209 $string = str_replace("\327", '&#215;', $string);
210 $string = str_replace("\330", '&#216;', $string);
211 $string = str_replace("\331", '&#217;', $string);
212 $string = str_replace("\332", '&#218;', $string);
213 $string = str_replace("\333", '&#219;', $string);
214 $string = str_replace("\334", '&#220;', $string);
215 $string = str_replace("\335", '&#221;', $string);
216 $string = str_replace("\336", '&#222;', $string);
217 $string = str_replace("\337", '&#223;', $string);
218 $string = str_replace("\340", '&#224;', $string);
219 $string = str_replace("\341", '&#225;', $string);
220 $string = str_replace("\342", '&#226;', $string);
221 $string = str_replace("\343", '&#227;', $string);
222 $string = str_replace("\344", '&#228;', $string);
223 $string = str_replace("\345", '&#229;', $string);
224 $string = str_replace("\346", '&#230;', $string);
225 $string = str_replace("\347", '&#231;', $string);
226 $string = str_replace("\350", '&#232;', $string);
227 $string = str_replace("\351", '&#233;', $string);
228 $string = str_replace("\352", '&#234;', $string);
229 $string = str_replace("\353", '&#235;', $string);
230 $string = str_replace("\354", '&#236;', $string);
231 $string = str_replace("\355", '&#237;', $string);
232 $string = str_replace("\356", '&#238;', $string);
233 $string = str_replace("\357", '&#239;', $string);
234 $string = str_replace("\360", '&#240;', $string);
235 $string = str_replace("\361", '&#241;', $string);
236 $string = str_replace("\362", '&#242;', $string);
237 $string = str_replace("\363", '&#243;', $string);
238 $string = str_replace("\364", '&#244;', $string);
239 $string = str_replace("\365", '&#245;', $string);
240 $string = str_replace("\366", '&#246;', $string);
241 $string = str_replace("\367", '&#247;', $string);
242 $string = str_replace("\370", '&#248;', $string);
243 $string = str_replace("\371", '&#249;', $string);
244 $string = str_replace("\372", '&#250;', $string);
245 $string = str_replace("\373", '&#251;', $string);
246 $string = str_replace("\374", '&#252;', $string);
247 $string = str_replace("\375", '&#253;', $string);
248 $string = str_replace("\376", '&#254;', $string);
249 $string = str_replace("\377", '&#255;', $string);
04563822 250 }
251 }
1fd97780 252
253 return ($string);
254 }
255
a89c13f5 256 // iso-8859-2 is used for some eastern European languages
257 function charset_decode_iso_8859_2 ($string) {
258 global $default_charset;
259
066c374f 260 if (strtolower($default_charset) == 'iso-8859-2') {
a89c13f5 261 return $string;
262 } else {
263 // Only do the slow convert if there are 8-bit characters
264 if (ereg("[\200-\377]", $string)) {
265 // NO-BREAK SPACE
066c374f 266 $string = str_replace("\240", '&#160;', $string);
a89c13f5 267 // LATIN CAPITAL LETTER A WITH OGONEK
066c374f 268 $string = str_replace("\241", '&#260;', $string);
a89c13f5 269 // BREVE
066c374f 270 $string = str_replace("\242", '&#728;', $string);
a89c13f5 271 // LATIN CAPITAL LETTER L WITH STROKE
066c374f 272 $string = str_replace("\243", '&#321;', $string);
a89c13f5 273 // CURRENCY SIGN
066c374f 274 $string = str_replace("\244", '&#164;', $string);
a89c13f5 275 // LATIN CAPITAL LETTER L WITH CARON
066c374f 276 $string = str_replace("\245", '&#317;', $string);
a89c13f5 277 // LATIN CAPITAL LETTER S WITH ACUTE
066c374f 278 $string = str_replace("\246", '&#346;', $string);
a89c13f5 279 // SECTION SIGN
066c374f 280 $string = str_replace("\247", '&#167;', $string);
a89c13f5 281 // DIAERESIS
066c374f 282 $string = str_replace("\250", '&#168;', $string);
a89c13f5 283 // LATIN CAPITAL LETTER S WITH CARON
066c374f 284 $string = str_replace("\251", '&#352;', $string);
a89c13f5 285 // LATIN CAPITAL LETTER S WITH CEDILLA
066c374f 286 $string = str_replace("\252", '&#350;', $string);
a89c13f5 287 // LATIN CAPITAL LETTER T WITH CARON
066c374f 288 $string = str_replace("\253", '&#356;', $string);
a89c13f5 289 // LATIN CAPITAL LETTER Z WITH ACUTE
066c374f 290 $string = str_replace("\254", '&#377;', $string);
a89c13f5 291 // SOFT HYPHEN
066c374f 292 $string = str_replace("\255", '&#173;', $string);
a89c13f5 293 // LATIN CAPITAL LETTER Z WITH CARON
066c374f 294 $string = str_replace("\256", '&#381;', $string);
a89c13f5 295 // LATIN CAPITAL LETTER Z WITH DOT ABOVE
066c374f 296 $string = str_replace("\257", '&#379;', $string);
a89c13f5 297 // DEGREE SIGN
066c374f 298 $string = str_replace("\260", '&#176;', $string);
a89c13f5 299 // LATIN SMALL LETTER A WITH OGONEK
066c374f 300 $string = str_replace("\261", '&#261;', $string);
a89c13f5 301 // OGONEK
066c374f 302 $string = str_replace("\262", '&#731;', $string);
a89c13f5 303 // LATIN SMALL LETTER L WITH STROKE
066c374f 304 $string = str_replace("\263", '&#322;', $string);
a89c13f5 305 // ACUTE ACCENT
066c374f 306 $string = str_replace("\264", '&#180;', $string);
a89c13f5 307 // LATIN SMALL LETTER L WITH CARON
066c374f 308 $string = str_replace("\265", '&#318;', $string);
a89c13f5 309 // LATIN SMALL LETTER S WITH ACUTE
066c374f 310 $string = str_replace("\266", '&#347;', $string);
a89c13f5 311 // CARON
066c374f 312 $string = str_replace("\267", '&#711;', $string);
a89c13f5 313 // CEDILLA
066c374f 314 $string = str_replace("\270", '&#184;', $string);
a89c13f5 315 // LATIN SMALL LETTER S WITH CARON
066c374f 316 $string = str_replace("\271", '&#353;', $string);
a89c13f5 317 // LATIN SMALL LETTER S WITH CEDILLA
066c374f 318 $string = str_replace("\272", '&#351;', $string);
a89c13f5 319 // LATIN SMALL LETTER T WITH CARON
066c374f 320 $string = str_replace("\273", '&#357;', $string);
a89c13f5 321 // LATIN SMALL LETTER Z WITH ACUTE
066c374f 322 $string = str_replace("\274", '&#378;', $string);
a89c13f5 323 // DOUBLE ACUTE ACCENT
066c374f 324 $string = str_replace("\275", '&#733;', $string);
a89c13f5 325 // LATIN SMALL LETTER Z WITH CARON
066c374f 326 $string = str_replace("\276", '&#382;', $string);
a89c13f5 327 // LATIN SMALL LETTER Z WITH DOT ABOVE
066c374f 328 $string = str_replace("\277", '&#380;', $string);
a89c13f5 329 // LATIN CAPITAL LETTER R WITH ACUTE
066c374f 330 $string = str_replace("\300", '&#340;', $string);
a89c13f5 331 // LATIN CAPITAL LETTER A WITH ACUTE
066c374f 332 $string = str_replace("\301", '&#193;', $string);
a89c13f5 333 // LATIN CAPITAL LETTER A WITH CIRCUMFLEX
066c374f 334 $string = str_replace("\302", '&#194;', $string);
a89c13f5 335 // LATIN CAPITAL LETTER A WITH BREVE
066c374f 336 $string = str_replace("\303", '&#258;', $string);
a89c13f5 337 // LATIN CAPITAL LETTER A WITH DIAERESIS
066c374f 338 $string = str_replace("\304", '&#196;', $string);
a89c13f5 339 // LATIN CAPITAL LETTER L WITH ACUTE
066c374f 340 $string = str_replace("\305", '&#313;', $string);
a89c13f5 341 // LATIN CAPITAL LETTER C WITH ACUTE
066c374f 342 $string = str_replace("\306", '&#262;', $string);
a89c13f5 343 // LATIN CAPITAL LETTER C WITH CEDILLA
066c374f 344 $string = str_replace("\307", '&#199;', $string);
a89c13f5 345 // LATIN CAPITAL LETTER C WITH CARON
066c374f 346 $string = str_replace("\310", '&#268;', $string);
a89c13f5 347 // LATIN CAPITAL LETTER E WITH ACUTE
066c374f 348 $string = str_replace("\311", '&#201;', $string);
a89c13f5 349 // LATIN CAPITAL LETTER E WITH OGONEK
066c374f 350 $string = str_replace("\312", '&#280;', $string);
a89c13f5 351 // LATIN CAPITAL LETTER E WITH DIAERESIS
066c374f 352 $string = str_replace("\313", '&#203;', $string);
a89c13f5 353 // LATIN CAPITAL LETTER E WITH CARON
066c374f 354 $string = str_replace("\314", '&#282;', $string);
a89c13f5 355 // LATIN CAPITAL LETTER I WITH ACUTE
066c374f 356 $string = str_replace("\315", '&#205;', $string);
a89c13f5 357 // LATIN CAPITAL LETTER I WITH CIRCUMFLEX
066c374f 358 $string = str_replace("\316", '&#206;', $string);
a89c13f5 359 // LATIN CAPITAL LETTER D WITH CARON
066c374f 360 $string = str_replace("\317", '&#270;', $string);
a89c13f5 361 // LATIN CAPITAL LETTER D WITH STROKE
066c374f 362 $string = str_replace("\320", '&#272;', $string);
a89c13f5 363 // LATIN CAPITAL LETTER N WITH ACUTE
066c374f 364 $string = str_replace("\321", '&#323;', $string);
a89c13f5 365 // LATIN CAPITAL LETTER N WITH CARON
066c374f 366 $string = str_replace("\322", '&#327;', $string);
a89c13f5 367 // LATIN CAPITAL LETTER O WITH ACUTE
066c374f 368 $string = str_replace("\323", '&#211;', $string);
a89c13f5 369 // LATIN CAPITAL LETTER O WITH CIRCUMFLEX
066c374f 370 $string = str_replace("\324", '&#212;', $string);
a89c13f5 371 // LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
066c374f 372 $string = str_replace("\325", '&#336;', $string);
a89c13f5 373 // LATIN CAPITAL LETTER O WITH DIAERESIS
066c374f 374 $string = str_replace("\326", '&#214;', $string);
a89c13f5 375 // MULTIPLICATION SIGN
066c374f 376 $string = str_replace("\327", '&#215;', $string);
a89c13f5 377 // LATIN CAPITAL LETTER R WITH CARON
066c374f 378 $string = str_replace("\330", '&#344;', $string);
a89c13f5 379 // LATIN CAPITAL LETTER U WITH RING ABOVE
066c374f 380 $string = str_replace("\331", '&#366;', $string);
a89c13f5 381 // LATIN CAPITAL LETTER U WITH ACUTE
066c374f 382 $string = str_replace("\332", '&#218;', $string);
a89c13f5 383 // LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
066c374f 384 $string = str_replace("\333", '&#368;', $string);
a89c13f5 385 // LATIN CAPITAL LETTER U WITH DIAERESIS
066c374f 386 $string = str_replace("\334", '&#220;', $string);
a89c13f5 387 // LATIN CAPITAL LETTER Y WITH ACUTE
066c374f 388 $string = str_replace("\335", '&#221;', $string);
a89c13f5 389 // LATIN CAPITAL LETTER T WITH CEDILLA
066c374f 390 $string = str_replace("\336", '&#354;', $string);
a89c13f5 391 // LATIN SMALL LETTER SHARP S
066c374f 392 $string = str_replace("\337", '&#223;', $string);
a89c13f5 393 // LATIN SMALL LETTER R WITH ACUTE
066c374f 394 $string = str_replace("\340", '&#341;', $string);
a89c13f5 395 // LATIN SMALL LETTER A WITH ACUTE
066c374f 396 $string = str_replace("\341", '&#225;', $string);
a89c13f5 397 // LATIN SMALL LETTER A WITH CIRCUMFLEX
066c374f 398 $string = str_replace("\342", '&#226;', $string);
a89c13f5 399 // LATIN SMALL LETTER A WITH BREVE
066c374f 400 $string = str_replace("\343", '&#259;', $string);
a89c13f5 401 // LATIN SMALL LETTER A WITH DIAERESIS
066c374f 402 $string = str_replace("\344", '&#228;', $string);
a89c13f5 403 // LATIN SMALL LETTER L WITH ACUTE
066c374f 404 $string = str_replace("\345", '&#314;', $string);
a89c13f5 405 // LATIN SMALL LETTER C WITH ACUTE
066c374f 406 $string = str_replace("\346", '&#263;', $string);
a89c13f5 407 // LATIN SMALL LETTER C WITH CEDILLA
066c374f 408 $string = str_replace("\347", '&#231;', $string);
a89c13f5 409 // LATIN SMALL LETTER C WITH CARON
066c374f 410 $string = str_replace("\350", '&#269;', $string);
a89c13f5 411 // LATIN SMALL LETTER E WITH ACUTE
066c374f 412 $string = str_replace("\351", '&#233;', $string);
a89c13f5 413 // LATIN SMALL LETTER E WITH OGONEK
066c374f 414 $string = str_replace("\352", '&#281;', $string);
a89c13f5 415 // LATIN SMALL LETTER E WITH DIAERESIS
066c374f 416 $string = str_replace("\353", '&#235;', $string);
a89c13f5 417 // LATIN SMALL LETTER E WITH CARON
066c374f 418 $string = str_replace("\354", '&#283;', $string);
a89c13f5 419 // LATIN SMALL LETTER I WITH ACUTE
066c374f 420 $string = str_replace("\355", '&#237;', $string);
a89c13f5 421 // LATIN SMALL LETTER I WITH CIRCUMFLEX
066c374f 422 $string = str_replace("\356", '&#238;', $string);
a89c13f5 423 // LATIN SMALL LETTER D WITH CARON
066c374f 424 $string = str_replace("\357", '&#271;', $string);
a89c13f5 425 // LATIN SMALL LETTER D WITH STROKE
066c374f 426 $string = str_replace("\360", '&#273;', $string);
a89c13f5 427 // LATIN SMALL LETTER N WITH ACUTE
066c374f 428 $string = str_replace("\361", '&#324;', $string);
a89c13f5 429 // LATIN SMALL LETTER N WITH CARON
066c374f 430 $string = str_replace("\362", '&#328;', $string);
a89c13f5 431 // LATIN SMALL LETTER O WITH ACUTE
066c374f 432 $string = str_replace("\363", '&#243;', $string);
a89c13f5 433 // LATIN SMALL LETTER O WITH CIRCUMFLEX
066c374f 434 $string = str_replace("\364", '&#244;', $string);
a89c13f5 435 // LATIN SMALL LETTER O WITH DOUBLE ACUTE
066c374f 436 $string = str_replace("\365", '&#337;', $string);
a89c13f5 437 // LATIN SMALL LETTER O WITH DIAERESIS
066c374f 438 $string = str_replace("\366", '&#246;', $string);
a89c13f5 439 // DIVISION SIGN
066c374f 440 $string = str_replace("\367", '&#247;', $string);
a89c13f5 441 // LATIN SMALL LETTER R WITH CARON
066c374f 442 $string = str_replace("\370", '&#345;', $string);
a89c13f5 443 // LATIN SMALL LETTER U WITH RING ABOVE
066c374f 444 $string = str_replace("\371", '&#367;', $string);
a89c13f5 445 // LATIN SMALL LETTER U WITH ACUTE
066c374f 446 $string = str_replace("\372", '&#250;', $string);
a89c13f5 447 // LATIN SMALL LETTER U WITH DOUBLE ACUTE
066c374f 448 $string = str_replace("\373", '&#369;', $string);
a89c13f5 449 // LATIN SMALL LETTER U WITH DIAERESIS
066c374f 450 $string = str_replace("\374", '&#252;', $string);
a89c13f5 451 // LATIN SMALL LETTER Y WITH ACUTE
066c374f 452 $string = str_replace("\375", '&#253;', $string);
a89c13f5 453 // LATIN SMALL LETTER T WITH CEDILLA
066c374f 454 $string = str_replace("\376", '&#355;', $string);
a89c13f5 455 // DOT ABOVE
066c374f 456 $string = str_replace("\377", '&#729;', $string);
a89c13f5 457 }
458 }
459 return $string;
460 }
461
0a86e9f3 462 // iso-8859-7 is Greek.
209e2f82 463 function charset_decode_iso_8859_7 ($string) {
04563822 464 global $default_charset;
173ed887 465
066c374f 466 if (strtolower($default_charset) == 'iso-8859-7') {
04563822 467 return $string;
468 } else {
469 // Only do the slow convert if there are 8-bit characters
470 if (ereg("[\200-\377]", $string)) {
471 // Some diverse characters in the beginning
066c374f 472 $string = str_replace("\240", '&#160;', $string);
473 $string = str_replace("\241", '&#8216;', $string);
474 $string = str_replace("\242", '&#8217;', $string);
475 $string = str_replace("\243", '&#163;', $string);
476 $string = str_replace("\246", '&#166;', $string);
477 $string = str_replace("\247", '&#167;', $string);
478 $string = str_replace("\250", '&#168;', $string);
479 $string = str_replace("\251", '&#169;', $string);
480 $string = str_replace("\253", '&#171;', $string);
481 $string = str_replace("\254", '&#172;', $string);
482 $string = str_replace("\255", '&#173;', $string);
483 $string = str_replace("\257", '&#8213;', $string);
484 $string = str_replace("\260", '&#176;', $string);
485 $string = str_replace("\261", '&#177;', $string);
486 $string = str_replace("\262", '&#178;', $string);
487 $string = str_replace("\263", '&#179;', $string);
04563822 488
066c374f 489 // Horizontal bar (parentheki pavla)
490 $string = str_replace ("\257", '&#8213;', $string);
04563822 491
492 // ISO-8859-7 characters from 11/04 (0xB4) to 11/06 (0xB6)
493 // These are Unicode 900-902
494 while (ereg("([\264-\266])", $string, $res)) {
066c374f 495 $replace = '&#' . (ord($res[1])+720) . ';';
04563822 496 $string = str_replace($res[1], $replace, $string);
497 }
498
499 // 11/07 (0xB7) Middle dot is the same in iso-8859-1
066c374f 500 $string = str_replace("\267", '&#183;', $string);
04563822 501
502 // ISO-8859-7 characters from 11/08 (0xB8) to 11/10 (0xBA)
503 // These are Unicode 900-902
504 while (ereg("([\270-\272])", $string, $res)) {
066c374f 505 $replace = '&#' . (ord($res[1])+720) . ";";
04563822 506 $string = str_replace($res[1], $replace, $string);
507 }
508
509 // 11/11 (0xBB) Right angle quotation mark is the same as in
510 // iso-8859-1
066c374f 511 $string = str_replace("\273", '&#187;', $string);
04563822 512
066c374f 513 // And now the rest of the charset
04563822 514 while (ereg("([\274-\376])", $string, $res)) {
066c374f 515 $replace = '&#' . (ord($res[1])+720) . ';';
04563822 516 $string = str_replace($res[1], $replace, $string);
517 }
518 }
173ed887 519 }
520
521 return $string;
522 }
523
a89c13f5 524 // iso-8859-15 is Latin 9 and has very much the same use as Latin 1
1fd97780 525 // but has the Euro symbol and some characters needed for French.
526 function charset_decode_iso_8859_15 ($string) {
527 // Euro sign
066c374f 528 $string = str_replace ("\244", '&#8364;', $string);
1fd97780 529 // Latin capital letter S with caron
066c374f 530 $string = str_replace ("\244", '&#352;', $string);
1fd97780 531 // Latin small letter s with caron
066c374f 532 $string = str_replace ("\250", '&#353;', $string);
1fd97780 533 // Latin capital letter Z with caron
066c374f 534 $string = str_replace ("\264", '&#381;', $string);
1fd97780 535 // Latin small letter z with caron
066c374f 536 $string = str_replace ("\270", '&#382;', $string);
1fd97780 537 // Latin capital ligature OE
066c374f 538 $string = str_replace ("\274", '&#338;', $string);
1fd97780 539 // Latin small ligature oe
066c374f 540 $string = str_replace ("\275", '&#339;', $string);
1fd97780 541 // Latin capital letter Y with diaeresis
066c374f 542 $string = str_replace ("\276", '&#376;', $string);
1fd97780 543
04563822 544 return (charset_decode_iso_8859_1($string));
1fd97780 545 }
546
17ce8467 547 // ISO-8859-15 is Cyrillic
548 function charset_decode_iso_8859_5 ($string) {
d23e472b 549 // Convert to KOI8-R, then return this decoded.
066c374f 550 $string = convert_cyr_string($string, 'i', 'k');
d23e472b 551 return charset_decode_koi8r($string);
17ce8467 552 }
553
173ed887 554 // Remove all 8 bit characters from all other ISO-8859 character sets
1fd97780 555 function charset_decode_iso_8859_default ($string) {
556 return (strtr($string, "\240\241\242\243\244\245\246\247".
557 "\250\251\252\253\254\255\256\257".
558 "\260\261\262\263\264\265\266\267".
559 "\270\271\272\273\274\275\276\277".
560 "\300\301\302\303\304\305\306\307".
561 "\310\311\312\313\314\315\316\317".
562 "\320\321\322\323\324\325\326\327".
563 "\330\331\332\333\334\335\336\337".
564 "\340\341\342\343\344\345\346\347".
565 "\350\351\352\353\354\355\356\357".
566 "\360\361\362\363\364\365\366\367".
567 "\370\371\372\373\374\375\376\377",
568 "????????????????????????????????????????".
569 "????????????????????????????????????????".
570 "????????????????????????????????????????".
571 "????????"));
572
573 }
574
575 // This is the same as ISO-646-NO and is used by some
576 // Microsoft programs when sending Norwegian characters
577 function charset_decode_ns_4551_1 ($string) {
578 // These characters are:
579 // Latin capital letter AE
580 // Latin capital letter O with stroke
581 // Latin capital letter A with ring above
582 // and the same as small letters
583