2b7d5f40659b980fa8a275a21274aa6aeca98563
6 ** This file contains variuos functions that are needed to do
7 ** internationalization of SquirrelMail.
9 ** Internally the output character set is used. Other characters are
10 ** encoded using Unicode entities according to HTML 4.0.
16 // This array specifies the available languages.
17 $languages["en"]["NAME"] = "English";
18 $languages["no"]["NAME"] = "Norwegian (Bokmål)";
19 $languages["no"]["CHARSET"] = "iso-8859-1";
20 $languages["no_NO_ny"]["NAME"] = "Norwegian (Nynorsk)";
21 $languages["no_NO_ny"]["CHARSET"] = "iso-8859-1";
22 $languages["de"]["NAME"] = "Deutsch";
23 $languages["de"]["CHARSET"] = "iso-8859-1";
24 $languages["ru"]["NAME"] = "Russian KOI8-R";
25 $languages["ru"]["CHARSET"] = "koi8-r";
26 $languages["pl"]["NAME"] = "Polish";
27 $languages["pl"]["CHARSET"] = "iso-8859-2";
28 $languages["sv"]["NAME"] = "Swedish";
29 $languages["sv"]["CHARSET"] = "iso-8859-1";
30 $languages["nl"]["NAME"] = "Dutch";
31 $languages["nl"]["CHARSET"] = "iso-8859-1";
32 $languages["pt_BR"]["NAME"] = "Portuguese (Brazil)";
33 $languages["pt_BR"]["CHARSET"] = "iso-8859-1";
34 $languages["fr"]["NAME"] = "French";
35 $languages["fr"]["CHARSET"] = "iso-8859-1";
36 $languages["it"]["NAME"] = "Italian";
37 $languages["it"]["CHARSET"] = "iso-8859-1";
38 $languages["cs"]["NAME"] = "Czech";
39 $languages["cs"]["CHARSET"] = "iso-8859-2";
40 $languages["es"]["NAME"] = "Spanish";
41 $languages["es"]["CHARSET"] = "iso-8859-1";
42 $languages["ko"]["NAME"] = "Korean";
43 $languages["ko"]["CHARSET"] = "euc-KR";
44 $languages["ca"]["NAME"] = "Catalan";
45 $languages["ca"]["CHARSET"] = "iso-8859-1";
47 // Decodes a string to the internal encoding from the given charset
48 function charset_decode ($charset, $string) {
51 // All HTML special characters are 7 bit and can be replaced first
52 $string = htmlspecialchars ($string);
54 $charset = strtolower($charset);
56 if ($debug_mime) $string = $charset.":".$string;
58 if (ereg("iso-8859-(.*)", $charset, $res)) {
60 return charset_decode_iso_8859_1 ($string);
61 else if ($res[1] == "2")
62 return charset_decode_iso_8859_2 ($string);
63 else if ($res[1] == "7")
64 return charset_decode_iso_8859_7 ($string);
65 else if ($res[1] == "15")
66 return charset_decode_iso_8859_15 ($string);
68 return charset_decode_iso_8859_default ($string);
69 } else if ($charset == "ns_4551-1") {
70 return charset_decode_ns_4551_1 ($string);
71 } else if ($charset == "koi8-r") {
72 return charset_decode_koi8r ($string);
77 // iso-8859-1 is the same as Latin 1 and is normally used
79 function charset_decode_iso_8859_1 ($string) {
80 global $default_charset;
82 if (strtolower($default_charset) == "iso-8859-1") {
85 // Only do the slow convert if there are 8-bit characters
86 if (ereg("[\200-\377]", $string)) {
87 $string = str_replace("\201", "", $string);
88 $string = str_replace("\202", "‚", $string);
89 $string = str_replace("\203", "ƒ", $string);
90 $string = str_replace("\204", "„", $string);
91 $string = str_replace("\205", "…", $string);
92 $string = str_replace("\206", "†", $string);
93 $string = str_replace("\207", "‡", $string);
94 $string = str_replace("\210", "ˆ", $string);
95 $string = str_replace("\211", "‰", $string);
96 $string = str_replace("\212", "Š", $string);
97 $string = str_replace("\213", "‹", $string);
98 $string = str_replace("\214", "Œ", $string);
99 $string = str_replace("\215", "", $string);
100 $string = str_replace("\216", "Ž", $string);
101 $string = str_replace("\217", "", $string);
102 $string = str_replace("\220", "", $string);
103 $string = str_replace("\221", "‘", $string);
104 $string = str_replace("\222", "’", $string);
105 $string = str_replace("\223", "“", $string);
106 $string = str_replace("\224", "”", $string);
107 $string = str_replace("\225", "•", $string);
108 $string = str_replace("\226", "–", $string);
109 $string = str_replace("\227", "—", $string);
110 $string = str_replace("\230", "˜", $string);
111 $string = str_replace("\231", "™", $string);
112 $string = str_replace("\232", "š", $string);
113 $string = str_replace("\233", "›", $string);
114 $string = str_replace("\234", "œ", $string);
115 $string = str_replace("\235", "", $string);
116 $string = str_replace("\236", "ž", $string);
117 $string = str_replace("\237", "Ÿ", $string);
118 $string = str_replace("\240", " ", $string);
119 $string = str_replace("\241", "¡", $string);
120 $string = str_replace("\242", "¢", $string);
121 $string = str_replace("\243", "£", $string);
122 $string = str_replace("\244", "¤", $string);
123 $string = str_replace("\245", "¥", $string);
124 $string = str_replace("\246", "¦", $string);
125 $string = str_replace("\247", "§", $string);
126 $string = str_replace("\250", "¨", $string);
127 $string = str_replace("\251", "©", $string);
128 $string = str_replace("\252", "ª", $string);
129 $string = str_replace("\253", "«", $string);
130 $string = str_replace("\254", "¬", $string);
131 $string = str_replace("\255", "­", $string);
132 $string = str_replace("\256", "®", $string);
133 $string = str_replace("\257", "¯", $string);
134 $string = str_replace("\260", "°", $string);
135 $string = str_replace("\261", "±", $string);
136 $string = str_replace("\262", "²", $string);
137 $string = str_replace("\263", "³", $string);
138 $string = str_replace("\264", "´", $string);
139 $string = str_replace("\265", "µ", $string);
140 $string = str_replace("\266", "¶", $string);
141 $string = str_replace("\267", "·", $string);
142 $string = str_replace("\270", "¸", $string);
143 $string = str_replace("\271", "¹", $string);
144 $string = str_replace("\272", "º", $string);
145 $string = str_replace("\273", "»", $string);
146 $string = str_replace("\274", "¼", $string);
147 $string = str_replace("\275", "½", $string);
148 $string = str_replace("\276", "¾", $string);
149 $string = str_replace("\277", "¿", $string);
150 $string = str_replace("\300", "À", $string);
151 $string = str_replace("\301", "Á", $string);
152 $string = str_replace("\302", "Â", $string);
153 $string = str_replace("\303", "Ã", $string);
154 $string = str_replace("\304", "Ä", $string);
155 $string = str_replace("\305", "Å", $string);
156 $string = str_replace("\306", "Æ", $string);
157 $string = str_replace("\307", "Ç", $string);
158 $string = str_replace("\310", "È", $string);
159 $string = str_replace("\311", "É", $string);
160 $string = str_replace("\312", "Ê", $string);
161 $string = str_replace("\313", "Ë", $string);
162 $string = str_replace("\314", "Ì", $string);
163 $string = str_replace("\315", "Í", $string);
164 $string = str_replace("\316", "Î", $string);
165 $string = str_replace("\317", "Ï", $string);
166 $string = str_replace("\320", "Ð", $string);
167 $string = str_replace("\321", "Ñ", $string);
168 $string = str_replace("\322", "Ò", $string);
169 $string = str_replace("\323", "Ó", $string);
170 $string = str_replace("\324", "Ô", $string);
171 $string = str_replace("\325", "Õ", $string);
172 $string = str_replace("\326", "Ö", $string);
173 $string = str_replace("\327", "×", $string);
174 $string = str_replace("\330", "Ø", $string);
175 $string = str_replace("\331", "Ù", $string);
176 $string = str_replace("\332", "Ú", $string);
177 $string = str_replace("\333", "Û", $string);
178 $string = str_replace("\334", "Ü", $string);
179 $string = str_replace("\335", "Ý", $string);
180 $string = str_replace("\336", "Þ", $string);
181 $string = str_replace("\337", "ß", $string);
182 $string = str_replace("\340", "à", $string);
183 $string = str_replace("\341", "á", $string);
184 $string = str_replace("\342", "â", $string);
185 $string = str_replace("\343", "ã", $string);
186 $string = str_replace("\344", "ä", $string);
187 $string = str_replace("\345", "å", $string);
188 $string = str_replace("\346", "æ", $string);
189 $string = str_replace("\347", "ç", $string);
190 $string = str_replace("\350", "è", $string);
191 $string = str_replace("\351", "é", $string);
192 $string = str_replace("\352", "ê", $string);
193 $string = str_replace("\353", "ë", $string);
194 $string = str_replace("\354", "ì", $string);
195 $string = str_replace("\355", "í", $string);
196 $string = str_replace("\356", "î", $string);
197 $string = str_replace("\357", "ï", $string);
198 $string = str_replace("\360", "ð", $string);
199 $string = str_replace("\361", "ñ", $string);
200 $string = str_replace("\362", "ò", $string);
201 $string = str_replace("\363", "ó", $string);
202 $string = str_replace("\364", "ô", $string);
203 $string = str_replace("\365", "õ", $string);
204 $string = str_replace("\366", "ö", $string);
205 $string = str_replace("\367", "÷", $string);
206 $string = str_replace("\370", "ø", $string);
207 $string = str_replace("\371", "ù", $string);
208 $string = str_replace("\372", "ú", $string);
209 $string = str_replace("\373", "û", $string);
210 $string = str_replace("\374", "ü", $string);
211 $string = str_replace("\375", "ý", $string);
212 $string = str_replace("\376", "þ", $string);
213 $string = str_replace("\377", "ÿ", $string);
220 // iso-8859-2 is used for some eastern European languages
221 function charset_decode_iso_8859_2 ($string) {
222 global $default_charset;
224 if (strtolower($default_charset) == "iso-8859-2") {
227 // Only do the slow convert if there are 8-bit characters
228 if (ereg("[\200-\377]", $string)) {
230 $string = str_replace("\240", " ", $string);
231 // LATIN CAPITAL LETTER A WITH OGONEK
232 $string = str_replace("\241", "Ą", $string);
234 $string = str_replace("\242", "˘", $string);
235 // LATIN CAPITAL LETTER L WITH STROKE
236 $string = str_replace("\243", "Ł", $string);
238 $string = str_replace("\244", "¤", $string);
239 // LATIN CAPITAL LETTER L WITH CARON
240 $string = str_replace("\245", "Ľ", $string);
241 // LATIN CAPITAL LETTER S WITH ACUTE
242 $string = str_replace("\246", "Ś", $string);
244 $string = str_replace("\247", "§", $string);
246 $string = str_replace("\250", "¨", $string);
247 // LATIN CAPITAL LETTER S WITH CARON
248 $string = str_replace("\251", "Š", $string);
249 // LATIN CAPITAL LETTER S WITH CEDILLA
250 $string = str_replace("\252", "Ş", $string);
251 // LATIN CAPITAL LETTER T WITH CARON
252 $string = str_replace("\253", "Ť", $string);
253 // LATIN CAPITAL LETTER Z WITH ACUTE
254 $string = str_replace("\254", "Ź", $string);
256 $string = str_replace("\255", "­", $string);
257 // LATIN CAPITAL LETTER Z WITH CARON
258 $string = str_replace("\256", "Ž", $string);
259 // LATIN CAPITAL LETTER Z WITH DOT ABOVE
260 $string = str_replace("\257", "Ż", $string);
262 $string = str_replace("\260", "°", $string);
263 // LATIN SMALL LETTER A WITH OGONEK
264 $string = str_replace("\261", "ą", $string);
266 $string = str_replace("\262", "˛", $string);
267 // LATIN SMALL LETTER L WITH STROKE
268 $string = str_replace("\263", "ł", $string);
270 $string = str_replace("\264", "´", $string);
271 // LATIN SMALL LETTER L WITH CARON
272 $string = str_replace("\265", "ľ", $string);
273 // LATIN SMALL LETTER S WITH ACUTE
274 $string = str_replace("\266", "ś", $string);
276 $string = str_replace("\267", "ˇ", $string);
278 $string = str_replace("\270", "¸", $string);
279 // LATIN SMALL LETTER S WITH CARON
280 $string = str_replace("\271", "š", $string);
281 // LATIN SMALL LETTER S WITH CEDILLA
282 $string = str_replace("\272", "ş", $string);
283 // LATIN SMALL LETTER T WITH CARON
284 $string = str_replace("\273", "ť", $string);
285 // LATIN SMALL LETTER Z WITH ACUTE
286 $string = str_replace("\274", "ź", $string);
287 // DOUBLE ACUTE ACCENT
288 $string = str_replace("\275", "˝", $string);
289 // LATIN SMALL LETTER Z WITH CARON
290 $string = str_replace("\276", "ž", $string);
291 // LATIN SMALL LETTER Z WITH DOT ABOVE
292 $string = str_replace("\277", "ż", $string);
293 // LATIN CAPITAL LETTER R WITH ACUTE
294 $string = str_replace("\300", "Ŕ", $string);
295 // LATIN CAPITAL LETTER A WITH ACUTE
296 $string = str_replace("\301", "Á", $string);
297 // LATIN CAPITAL LETTER A WITH CIRCUMFLEX
298 $string = str_replace("\302", "Â", $string);
299 // LATIN CAPITAL LETTER A WITH BREVE
300 $string = str_replace("\303", "Ă", $string);
301 // LATIN CAPITAL LETTER A WITH DIAERESIS
302 $string = str_replace("\304", "Ä", $string);
303 // LATIN CAPITAL LETTER L WITH ACUTE
304 $string = str_replace("\305", "Ĺ", $string);
305 // LATIN CAPITAL LETTER C WITH ACUTE
306 $string = str_replace("\306", "Ć", $string);
307 // LATIN CAPITAL LETTER C WITH CEDILLA
308 $string = str_replace("\307", "Ç", $string);
309 // LATIN CAPITAL LETTER C WITH CARON
310 $string = str_replace("\310", "Č", $string);
311 // LATIN CAPITAL LETTER E WITH ACUTE
312 $string = str_replace("\311", "É", $string);
313 // LATIN CAPITAL LETTER E WITH OGONEK
314 $string = str_replace("\312", "Ę", $string);
315 // LATIN CAPITAL LETTER E WITH DIAERESIS
316 $string = str_replace("\313", "Ë", $string);
317 // LATIN CAPITAL LETTER E WITH CARON
318 $string = str_replace("\314", "Ě", $string);
319 // LATIN CAPITAL LETTER I WITH ACUTE
320 $string = str_replace("\315", "Í", $string);
321 // LATIN CAPITAL LETTER I WITH CIRCUMFLEX
322 $string = str_replace("\316", "Î", $string);
323 // LATIN CAPITAL LETTER D WITH CARON
324 $string = str_replace("\317", "Ď", $string);
325 // LATIN CAPITAL LETTER D WITH STROKE
326 $string = str_replace("\320", "Đ", $string);
327 // LATIN CAPITAL LETTER N WITH ACUTE
328 $string = str_replace("\321", "Ń", $string);
329 // LATIN CAPITAL LETTER N WITH CARON
330 $string = str_replace("\322", "Ň", $string);
331 // LATIN CAPITAL LETTER O WITH ACUTE
332 $string = str_replace("\323", "Ó", $string);
333 // LATIN CAPITAL LETTER O WITH CIRCUMFLEX
334 $string = str_replace("\324", "Ô", $string);
335 // LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
336 $string = str_replace("\325", "Ő", $string);
337 // LATIN CAPITAL LETTER O WITH DIAERESIS
338 $string = str_replace("\326", "Ö", $string);
339 // MULTIPLICATION SIGN
340 $string = str_replace("\327", "×", $string);
341 // LATIN CAPITAL LETTER R WITH CARON
342 $string = str_replace("\330", "Ř", $string);
343 // LATIN CAPITAL LETTER U WITH RING ABOVE
344 $string = str_replace("\331", "Ů", $string);
345 // LATIN CAPITAL LETTER U WITH ACUTE
346 $string = str_replace("\332", "Ú", $string);
347 // LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
348 $string = str_replace("\333", "Ű", $string);
349 // LATIN CAPITAL LETTER U WITH DIAERESIS
350 $string = str_replace("\334", "Ü", $string);
351 // LATIN CAPITAL LETTER Y WITH ACUTE
352 $string = str_replace("\335", "Ý", $string);
353 // LATIN CAPITAL LETTER T WITH CEDILLA
354 $string = str_replace("\336", "Ţ", $string);
355 // LATIN SMALL LETTER SHARP S
356 $string = str_replace("\337", "ß", $string);
357 // LATIN SMALL LETTER R WITH ACUTE
358 $string = str_replace("\340", "ŕ", $string);
359 // LATIN SMALL LETTER A WITH ACUTE
360 $string = str_replace("\341", "á", $string);
361 // LATIN SMALL LETTER A WITH CIRCUMFLEX
362 $string = str_replace("\342", "â", $string);
363 // LATIN SMALL LETTER A WITH BREVE
364 $string = str_replace("\343", "ă", $string);
365 // LATIN SMALL LETTER A WITH DIAERESIS
366 $string = str_replace("\344", "ä", $string);
367 // LATIN SMALL LETTER L WITH ACUTE
368 $string = str_replace("\345", "ĺ", $string);
369 // LATIN SMALL LETTER C WITH ACUTE
370 $string = str_replace("\346", "ć", $string);
371 // LATIN SMALL LETTER C WITH CEDILLA
372 $string = str_replace("\347", "ç", $string);
373 // LATIN SMALL LETTER C WITH CARON
374 $string = str_replace("\350", "č", $string);
375 // LATIN SMALL LETTER E WITH ACUTE
376 $string = str_replace("\351", "é", $string);
377 // LATIN SMALL LETTER E WITH OGONEK
378 $string = str_replace("\352", "ę", $string);
379 // LATIN SMALL LETTER E WITH DIAERESIS
380 $string = str_replace("\353", "ë", $string);
381 // LATIN SMALL LETTER E WITH CARON
382 $string = str_replace("\354", "ě", $string);
383 // LATIN SMALL LETTER I WITH ACUTE
384 $string = str_replace("\355", "í", $string);
385 // LATIN SMALL LETTER I WITH CIRCUMFLEX
386 $string = str_replace("\356", "î", $string);
387 // LATIN SMALL LETTER D WITH CARON
388 $string = str_replace("\357", "ď", $string);
389 // LATIN SMALL LETTER D WITH STROKE
390 $string = str_replace("\360", "đ", $string);
391 // LATIN SMALL LETTER N WITH ACUTE
392 $string = str_replace("\361", "ń", $string);
393 // LATIN SMALL LETTER N WITH CARON
394 $string = str_replace("\362", "ň", $string);
395 // LATIN SMALL LETTER O WITH ACUTE
396 $string = str_replace("\363", "ó", $string);
397 // LATIN SMALL LETTER O WITH CIRCUMFLEX
398 $string = str_replace("\364", "ô", $string);
399 // LATIN SMALL LETTER O WITH DOUBLE ACUTE
400 $string = str_replace("\365", "ő", $string);
401 // LATIN SMALL LETTER O WITH DIAERESIS
402 $string = str_replace("\366", "ö", $string);
404 $string = str_replace("\367", "÷", $string);
405 // LATIN SMALL LETTER R WITH CARON
406 $string = str_replace("\370", "ř", $string);
407 // LATIN SMALL LETTER U WITH RING ABOVE
408 $string = str_replace("\371", "ů", $string);
409 // LATIN SMALL LETTER U WITH ACUTE
410 $string = str_replace("\372", "ú", $string);
411 // LATIN SMALL LETTER U WITH DOUBLE ACUTE
412 $string = str_replace("\373", "ű", $string);
413 // LATIN SMALL LETTER U WITH DIAERESIS
414 $string = str_replace("\374", "ü", $string);
415 // LATIN SMALL LETTER Y WITH ACUTE
416 $string = str_replace("\375", "ý", $string);
417 // LATIN SMALL LETTER T WITH CEDILLA
418 $string = str_replace("\376", "ţ", $string);
420 $string = str_replace("\377", "˙", $string);
426 // iso-8859-7 is Greek.
427 function charset_decode_iso_8859_7 ($string) {
428 global $default_charset;
430 if (strtolower($default_charset) == "iso-8859-7") {
433 // Only do the slow convert if there are 8-bit characters
434 if (ereg("[\200-\377]", $string)) {
435 // Some diverse characters in the beginning
436 $string = str_replace("\240", " ", $string);
437 $string = str_replace("\241", "‘", $string);
438 $string = str_replace("\242", "’", $string);
439 $string = str_replace("\243", "£", $string);
440 $string = str_replace("\246", "¦", $string);
441 $string = str_replace("\247", "§", $string);
442 $string = str_replace("\250", "¨", $string);
443 $string = str_replace("\251", "©", $string);
444 $string = str_replace("\253", "«", $string);
445 $string = str_replace("\254", "¬", $string);
446 $string = str_replace("\255", "­", $string);
447 $string = str_replace("\257", "―", $string);
448 $string = str_replace("\260", "°", $string);
449 $string = str_replace("\261", "±", $string);
450 $string = str_replace("\262", "²", $string);
451 $string = str_replace("\263", "³", $string);
453 // Horizontal bar (parentheki pavla)
454 $string = str_replace ("\257", "―", $string);
456 // ISO-8859-7 characters from 11/04 (0xB4) to 11/06 (0xB6)
457 // These are Unicode 900-902
458 while (ereg("([\264-\266])", $string, $res)) {
459 $replace = "&#" . (ord($res[1])+
720) . ";";
460 $string = str_replace($res[1], $replace, $string);
463 // 11/07 (0xB7) Middle dot is the same in iso-8859-1
464 $string = str_replace("\267", "·", $string);
466 // ISO-8859-7 characters from 11/08 (0xB8) to 11/10 (0xBA)
467 // These are Unicode 900-902
468 while (ereg("([\270-\272])", $string, $res)) {
469 $replace = "&#" . (ord($res[1])+
720) . ";";
470 $string = str_replace($res[1], $replace, $string);
473 // 11/11 (0xBB) Right angle quotation mark is the same as in
475 $string = str_replace("\273", "»", $string);
477 // And now the rest of the charset
478 while (ereg("([\274-\376])", $string, $res)) {
479 $replace = "&#" . (ord($res[1])+
720) . ";";
480 $string = str_replace($res[1], $replace, $string);
488 // iso-8859-15 is Latin 9 and has very much the same use as Latin 1
489 // but has the Euro symbol and some characters needed for French.
490 function charset_decode_iso_8859_15 ($string) {
492 $string = str_replace ("\244", "€", $string);
493 // Latin capital letter S with caron
494 $string = str_replace ("\244", "Š", $string);
495 // Latin small letter s with caron
496 $string = str_replace ("\250", "š", $string);
497 // Latin capital letter Z with caron
498 $string = str_replace ("\264", "Ž", $string);
499 // Latin small letter z with caron
500 $string = str_replace ("\270", "ž", $string);
501 // Latin capital ligature OE
502 $string = str_replace ("\274", "Œ", $string);
503 // Latin small ligature oe
504 $string = str_replace ("\275", "œ", $string);
505 // Latin capital letter Y with diaeresis
506 $string = str_replace ("\276", "Ÿ", $string);
508 return (charset_decode_iso_8859_1($string));
511 // ISO-8859-15 is Cyrillic
512 function charset_decode_iso_8859_5 ($string) {
513 // Convert to KOI8-R, then return this decoded.
514 $string = convert_cyr_string($string, "i", "k");
515 return charset_decode_koi8r($string);
518 // Remove all 8 bit characters from all other ISO-8859 character sets
519 function charset_decode_iso_8859_default ($string) {
520 return (strtr($string, "\240\241\242\243\244\245\246\247".
521 "\250\251\252\253\254\255\256\257".
522 "\260\261\262\263\264\265\266\267".
523 "\270\271\272\273\274\275\276\277".
524 "\300\301\302\303\304\305\306\307".
525 "\310\311\312\313\314\315\316\317".
526 "\320\321\322\323\324\325\326\327".
527 "\330\331\332\333\334\335\336\337".
528 "\340\341\342\343\344\345\346\347".
529 "\350\351\352\353\354\355\356\357".
530 "\360\361\362\363\364\365\366\367".
531 "\370\371\372\373\374\375\376\377",
532 "????????????????????????????????????????".
533 "????????????????????????????????????????".
534 "????????????????????????????????????????".
539 // This is the same as ISO-646-NO and is used by some
540 // Microsoft programs when sending Norwegian characters
541 function charset_decode_ns_4551_1 ($string) {
542 // These characters are:
543 // Latin capital letter AE
544 // Latin capital letter O with stroke
545 // Latin capital letter A with ring above
546 // and the same as small letters
547 return strtr ($string, "[\\]{|}", "ÆØÅæøå");
550 // KOI8-R is used to encode Russian mail (Cyrrilic). Defined in RFC
552 function charset_decode_koi8r ($string) {
553 global $default_charset;
555 if ($default_charset == "koi8-r") {
558 // Convert to Unicode HTML entities.
559 // This code is rather ineffective.
560 $string = str_replace("\200", "─", $string);
561 $string = str_replace("\201", "│", $string);
562 $string = str_replace("\202", "┌", $string);
563 $string = str_replace("\203", "┐", $string);
564 $string = str_replace("\204", "└", $string);
565 $string = str_replace("\205", "┘", $string);
566 $string = str_replace("\206", "├", $string);
567 $string = str_replace("\207", "┤", $string);
568 $string = str_replace("\210", "┬", $string);
569 $string = str_replace("\211", "┴", $string);
570 $string = str_replace("\212", "┼", $string);
571 $string = str_replace("\213", "▀", $string);
572 $string = str_replace("\214", "▄", $string);
573 $string = str_replace("\215", "█", $string);
574 $string = str_replace("\216", "▌", $string);
575 $string = str_replace("\217", "▐", $string);
576 $string = str_replace("\220", "░", $string);
577 $string = str_replace("\221", "▒", $string);
578 $string = str_replace("\222", "▓", $string);
579 $string = str_replace("\223", "⌠", $string);
580 $string = str_replace("\224", "■", $string);
581 $string = str_replace("\225", "∙", $string);
582 $string = str_replace("\226", "√", $string);
583 $string = str_replace("\227", "≈", $string);
584 $string = str_replace("\230", "≤", $string);
585 $string = str_replace("\231", "≥", $string);
586 $string = str_replace("\232", " ", $string);
587 $string = str_replace("\233", "⌡", $string);
588 $string = str_replace("\234", "°", $string);
589 $string = str_replace("\235", "²", $string);
590 $string = str_replace("\236", "·", $string);
591 $string = str_replace("\237", "÷", $string);
592 $string = str_replace("\240", "═", $string);
593 $string = str_replace("\241", "║", $string);
594 $string = str_replace("\242", "╒", $string);
595 $string = str_replace("\243", "ё", $string);
596 $string = str_replace("\244", "╓", $string);
597 $string = str_replace("\245", "╔", $string);
598 $string = str_replace("\246", "╕", $string);
599 $string = str_replace("\247", "╖", $string);
600 $string = str_replace("\250", "╗", $string);
601 $string = str_replace("\251", "╘", $string);
602 $string = str_replace("\252", "╙", $string);
603 $string = str_replace("\253", "╚", $string);
604 $string = str_replace("\254", "╛", $string);
605 $string = str_replace("\255", "╜", $string);
606 $string = str_replace("\256", "╝", $string);
607 $string = str_replace("\257", "╞", $string);
608 $string = str_replace("\260", "╟", $string);
609 $string = str_replace("\261", "╠", $string);
610 $string = str_replace("\262", "╡", $string);
611 $string = str_replace("\263", "Ё", $string);
612 $string = str_replace("\264", "╢", $string);
613 $string = str_replace("\265", "╣", $string);
614 $string = str_replace("\266", "╤", $string);
615 $string = str_replace("\267", "╥", $string);
616 $string = str_replace("\270", "╦", $string);
617 $string = str_replace("\271", "╧", $string);
618 $string = str_replace("\272", "╨", $string);
619 $string = str_replace("\273", "╩", $string);
620 $string = str_replace("\274", "╪", $string);
621 $string = str_replace("\275", "╫", $string);
622 $string = str_replace("\276", "╬", $string);
623 $string = str_replace("\277", "©", $string);
624 $string = str_replace("\300", "ю", $string);
625 $string = str_replace("\301", "а", $string);
626 $string = str_replace("\302", "б", $string);
627 $string = str_replace("\303", "ц", $string);
628 $string = str_replace("\304", "д", $string);
629 $string = str_replace("\305", "е", $string);
630 $string = str_replace("\306", "ф", $string);
631 $string = str_replace("\307", "г", $string);
632 $string = str_replace("\310", "х", $string);
633 $string = str_replace("\311", "и", $string);
634 $string = str_replace("\312", "й", $string);
635 $string = str_replace("\313", "к", $string);
636 $string = str_replace("\314", "л", $string);
637 $string = str_replace("\315", "м", $string);
638 $string = str_replace("\316", "н", $string);
639 $string = str_replace("\317", "о", $string);
640 $string = str_replace("\320", "п", $string);
641 $string = str_replace("\321", "я", $string);
642 $string = str_replace("\322", "р", $string);
643 $string = str_replace("\323", "с", $string);
644 $string = str_replace("\324", "т", $string);
645 $string = str_replace("\325", "у", $string);
646 $string = str_replace("\326", "ж", $string);
647 $string = str_replace("\327", "в", $string);
648 $string = str_replace("\330", "ь", $string);
649 $string = str_replace("\331", "ы", $string);
650 $string = str_replace("\332", "з", $string);
651 $string = str_replace("\333", "ш", $string);
652 $string = str_replace("\334", "э", $string);
653 $string = str_replace("\335", "щ", $string);
654 $string = str_replace("\336", "ч", $string);
655 $string = str_replace("\337", "ъ", $string);
656 $string = str_replace("\340", "Ю", $string);
657 $string = str_replace("\341", "А", $string);
658 $string = str_replace("\342", "Б", $string);
659 $string = str_replace("\343", "Ц", $string);
660 $string = str_replace("\344", "Д", $string);
661 $string = str_replace("\345", "Е", $string);
662 $string = str_replace("\346", "Ф", $string);
663 $string = str_replace("\347", "Г", $string);
664 $string = str_replace("\350", "Х", $string);
665 $string = str_replace("\351", "И", $string);
666 $string = str_replace("\352", "Й", $string);
667 $string = str_replace("\353", "К", $string);
668 $string = str_replace("\354", "Л", $string);
669 $string = str_replace("\355", "М", $string);
670 $string = str_replace("\356", "Н", $string);
671 $string = str_replace("\357", "О", $string);
672 $string = str_replace("\360", "П", $string);
673 $string = str_replace("\361", "Я", $string);
674 $string = str_replace("\362", "Р", $string);
675 $string = str_replace("\363", "С", $string);
676 $string = str_replace("\364", "Т", $string);
677 $string = str_replace("\365", "У", $string);
678 $string = str_replace("\366", "Ж", $string);
679 $string = str_replace("\367", "В", $string);
680 $string = str_replace("\370", "Ь", $string);
681 $string = str_replace("\371", "Ы", $string);
682 $string = str_replace("\372", "З", $string);
683 $string = str_replace("\373", "Ш", $string);
684 $string = str_replace("\374", "Э", $string);
685 $string = str_replace("\375", "Щ", $string);
686 $string = str_replace("\376", "Ч", $string);
687 $string = str_replace("\377", "Ъ", $string);