Added experimental iso-8859-6 decoding support.
authortokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 15 Jun 2003 11:39:17 +0000 (11:39 +0000)
committertokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 15 Jun 2003 11:39:17 +0000 (11:39 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@5051 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/i18n.php

index 061ad1ef9890b55f1337862e68cbbd1421c7dd2e..fdaafaf610cda7781d18da36407f1854718a6aa4 100644 (file)
@@ -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", '&#160;',  $string);
+    $string = str_replace ("\244", '&#164;',  $string);
+    $string = str_replace ("\254", '&#1548;', $string);
+    $string = str_replace ("\255", '&#173;',  $string);
+    $string = str_replace ("\273", '&#1563;', $string);
+    $string = str_replace ("\277", '&#1567;', $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;