From ef82d2d5da81380d75bdfdfe7be4bbd9959f66f9 Mon Sep 17 00:00:00 2001 From: tokul Date: Sun, 15 Jun 2003 11:39:17 +0000 Subject: [PATCH] Added experimental iso-8859-6 decoding support. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@5051 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/i18n.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/functions/i18n.php b/functions/i18n.php index 061ad1ef..fdaafaf6 100644 --- a/functions/i18n.php +++ b/functions/i18n.php @@ -43,6 +43,8 @@ function charset_decode ($charset, $string) { $ret = charset_decode_iso_8859_4 ($string); } else if ($res[1] == '5') { $ret = charset_decode_iso_8859_5 ($string); + } else if ($res[1] == '6') { + $ret = charset_decode_iso_8859_6 ($string); } else if ($res[1] == '7') { $ret = charset_decode_iso_8859_7 ($string); } else if ($res[1] == '9') { @@ -533,6 +535,33 @@ function charset_decode_iso_8859_5 ($string) { return $string; } +/* + ISO/IEC 8859-6:1999 Latin/Arabic Alphabet +*/ +function charset_decode_iso_8859_6 ($string) { + global $default_charset; + + if (strtolower($default_charset) == 'iso-8859-6') + return $string; + + /* Only do the slow convert if there are 8-bit characters */ + if (! ereg("[\200-\377]", $string)) + return $string; + + $string = str_replace ("\240", ' ', $string); + $string = str_replace ("\244", '¤', $string); + $string = str_replace ("\254", '،', $string); + $string = str_replace ("\255", '­', $string); + $string = str_replace ("\273", '؛', $string); + $string = str_replace ("\277", '؟', $string); + // 193-218 -> 1569-1594 (+1376) + $string = preg_replace("/([\301-\332])/e","'&#' . (ord('\\1')+1376).';'",$string); + // 224-242 -> 1600-1618 (+1376) + $string = preg_replace("/([\340-\362])/e","'&#' . (ord('\\1')+1376).';'",$string); + + return ($string); +} + /* iso-8859-7 is Greek. */ function charset_decode_iso_8859_7 ($string) { global $default_charset; -- 2.25.1