From 173ed8870d11b6bf8c93c1ebfdbcc2f59e5ffe37 Mon Sep 17 00:00:00 2001 From: gustavf Date: Tue, 29 Feb 2000 14:29:37 +0000 Subject: [PATCH] Added support for iso-8859-1 (Latin/Greek alphabet). git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@251 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- TODO | 1 - functions/i18n.php | 44 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index be9c9469..39d37f16 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,6 @@ Ideas to be implemented ----------------------- -- Decode message bodies if they are quoted printable - Saving sent mail into folder "Sent" - Delete folders made robust - Go through each php file and assign it a constant diff --git a/functions/i18n.php b/functions/i18n.php index 0a08886b..5d76cc03 100644 --- a/functions/i18n.php +++ b/functions/i18n.php @@ -8,6 +8,7 @@ ** ** Internally iso-8859-1 is used as character set. Other characters ** are encoded using Unicode entities according to HTML 4.0. + ** **/ $i18n_php = true; @@ -22,6 +23,8 @@ if (ereg("iso-8859-(.*)", $charset, $res)) { if ($res[1] == "1") return charset_decode_iso_8859_1 ($string); + if ($res[1] == "7") + return charset_decode_iso_8859_7 ($string); else if ($res[1] == "15") return charset_decode_iso_8859_15 ($string); else @@ -45,6 +48,45 @@ return ($string); } + // iso-8859-1 is Greek. + function charset_decode_iso_8859_1 ($string) { + // Could not find Unicode equivalent of 0xA1 and 0xA2 + // 0xA4, 0xA5, 0xAA, 0xAE, 0xD2 and 0xFF should not be used + $string = strtr($string, "\241\242\244\245\252\256\322\377", + "????????"); + + // Horizontal bar (parentheki pavla) + while (ereg("\257", $string)) + $string = ereg_replace ("\257", "―", $string); + + // ISO-8859-7 characters from 11/04 (0xB4) to 11/06 (0xB6) + // These are Unicode 900-902 + while (ereg("([\264-\266])", $string, $res)) { + $replace = "&#.".ord($res[1])+720.";"; + ereg_repleace("[\264-\266]", $replace, $string); + } + + // 11/07 (0xB7) Middle dot is the same in iso-8859-1 + + // ISO-8859-7 characters from 11/08 (0xB8) to 11/10 (0xBA) + // These are Unicode 900-902 + while (ereg("([\270-\272])", $string, $res)) { + $replace = "&#.".ord($res[1])+720.";"; + ereg_repleace("[\270-\272]", $replace, $string); + } + + // 11/11 (0xBB) Right angle quotation mark is the same as in + // iso-8859-1 + + // And now the rest of the charset + while (ereg("([\273-\376])", $string, $res)) { + $replace = "&#.".ord($res[1])+720.";"; + ereg_repleace("[\273-\376]", $replace, $string); + } + + return $string; + } + // iso-8859-15 is Latin 15 and has very much the same use as Latin 1 // but has the Euro symbol and some characters needed for French. function charset_decode_iso_8859_15 ($string) { @@ -76,7 +118,7 @@ return ($string); } - // Remove al 8 bit characters from all other ISO-8859 character sets + // Remove all 8 bit characters from all other ISO-8859 character sets function charset_decode_iso_8859_default ($string) { return (strtr($string, "\240\241\242\243\244\245\246\247". "\250\251\252\253\254\255\256\257". -- 2.25.1