From 0e4337e7bc2c6596028cb0cfddb08454610b55e1 Mon Sep 17 00:00:00 2001 From: tokul Date: Sun, 12 Oct 2003 12:38:02 +0000 Subject: [PATCH] Added iso-ir-111 support. one of cyrillic charsets from mozilla's list. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@5910 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/decode/iso-ir-111.php | 159 ++++++++++++++++++++++++++++++++ functions/i18n.php | 3 + 2 files changed, 162 insertions(+) create mode 100644 functions/decode/iso-ir-111.php diff --git a/functions/decode/iso-ir-111.php b/functions/decode/iso-ir-111.php new file mode 100644 index 00000000..bd10ca04 --- /dev/null +++ b/functions/decode/iso-ir-111.php @@ -0,0 +1,159 @@ + + * Date: 05 March 1998 + * + * Original copyright: + * Copyright 1999 Computing Research Labs, New Mexico State University + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the ""Software""), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT + * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +function charset_decode_iso_ir_111 ($string) { + global $default_charset; + + if (strtolower($default_charset) == 'iso-ir-111') + return $string; + + /* Only do the slow convert if there are 8-bit characters */ + /* there is no 0x80-0x9F letters in ISO-IR-111 */ + if ( ! ereg("[\241-\377]", $string) ) + return $string; + + $iso_ir_111 = array( + "\xA0" => ' ', + "\xA1" => 'ђ', + "\xA2" => 'ѓ', + "\xA3" => 'ё', + "\xA4" => 'є', + "\xA5" => 'ѕ', + "\xA6" => 'і', + "\xA7" => 'ї', + "\xA8" => 'ј', + "\xA9" => 'љ', + "\xAA" => 'њ', + "\xAB" => 'ћ', + "\xAC" => 'ќ', + "\xAD" => '­', + "\xAE" => 'ў', + "\xAF" => 'џ', + "\xB0" => '№', + "\xB1" => 'Ђ', + "\xB2" => 'Ѓ', + "\xB3" => 'Ё', + "\xB4" => 'Є', + "\xB5" => 'Ѕ', + "\xB6" => 'І', + "\xB7" => 'Ї', + "\xB8" => 'Ј', + "\xB9" => 'Љ', + "\xBA" => 'Њ', + "\xBB" => 'Ћ', + "\xBC" => 'Ќ', + "\xBD" => '¤', + "\xBE" => 'Ў', + "\xBF" => 'Џ', + "\xC0" => 'ю', + "\xC1" => 'а', + "\xC2" => 'б', + "\xC3" => 'ц', + "\xC4" => 'д', + "\xC5" => 'е', + "\xC6" => 'ф', + "\xC7" => 'г', + "\xC8" => 'х', + "\xC9" => 'и', + "\xCA" => 'й', + "\xCB" => 'к', + "\xCC" => 'л', + "\xCD" => 'м', + "\xCE" => 'н', + "\xCF" => 'о', + "\xD0" => 'п', + "\xD1" => 'я', + "\xD2" => 'р', + "\xD3" => 'с', + "\xD4" => 'т', + "\xD5" => 'у', + "\xD6" => 'ж', + "\xD7" => 'в', + "\xD8" => 'ь', + "\xD9" => 'ы', + "\xDA" => 'з', + "\xDB" => 'ш', + "\xDC" => 'э', + "\xDD" => 'щ', + "\xDE" => 'ч', + "\xDF" => 'ъ', + "\xE0" => 'Ю', + "\xE1" => 'А', + "\xE2" => 'Б', + "\xE3" => 'Ц', + "\xE4" => 'Д', + "\xE5" => 'Е', + "\xE6" => 'Ф', + "\xE7" => 'Г', + "\xE8" => 'Х', + "\xE9" => 'И', + "\xEA" => 'Й', + "\xEB" => 'К', + "\xEC" => 'Л', + "\xED" => 'М', + "\xEE" => 'Н', + "\xEF" => 'О', + "\xF0" => 'П', + "\xF1" => 'Я', + "\xF2" => 'Р', + "\xF3" => 'С', + "\xF4" => 'Т', + "\xF5" => 'У', + "\xF6" => 'Ж', + "\xF7" => 'В', + "\xF8" => 'Ь', + "\xF9" => 'Ы', + "\xFA" => 'З', + "\xFB" => 'Ш', + "\xFC" => 'Э', + "\xFD" => 'Щ', + "\xFE" => 'Ч', + "\xFF" => 'Ъ' + ); + + $string = str_replace(array_keys($iso_ir_111), array_values($iso_ir_111), $string); + + return $string; +} + +?> \ No newline at end of file diff --git a/functions/i18n.php b/functions/i18n.php index 4600de33..4895301d 100644 --- a/functions/i18n.php +++ b/functions/i18n.php @@ -187,6 +187,9 @@ function charset_decode ($charset, $string) { } else if ($charset == 'ibm866') { include_once(SM_PATH . 'functions/decode/cp866.php'); $ret = charset_decode_cp866 ($string); + } else if ($charset == 'iso-ir-111') { + include_once(SM_PATH . 'functions/decode/iso-ir-111.php'); + $ret = charset_decode_iso_ir_111 ($string); } else if ($charset == 'tis-620') { include_once(SM_PATH . 'functions/decode/tis620.php'); $ret = charset_decode_tis620 ($string); -- 2.25.1