initialize $second var in order to prevent variable abuse in rg=on and fix
[squirrelmail.git] / functions / i18n.php
index d4799d268b0eb8af7edd291a1668390372537950..9f01614429a56f7f0c29293b54de4adab0d78d45 100644 (file)
@@ -1,16 +1,16 @@
 <?php
+
 /**
  * SquirrelMail internationalization functions
  *
- * Copyright (c) 1999-2005 The SquirrelMail Project Team
- * Licensed under the GNU GPL. For full terms see the file COPYING.
- *
  * This file contains variuos functions that are needed to do
  * internationalization of SquirrelMail.
  *
  * Internally the output character set is used. Other characters are
  * encoded using Unicode entities according to HTML 4.0.
  *
+ * @copyright &copy; 1999-2005 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
  * @subpackage i18n
@@ -134,7 +134,7 @@ function charset_decode ($charset, $string, $force_decode=false, $save_html=fals
 
     // Don't do conversion if charset is the same.
     if ( ! $force_decode && $charset == strtolower($default_charset) )
-        return ($save_html ? $strings : htmlspecialchars($string));
+        return ($save_html ? $string : htmlspecialchars($string));
 
     // catch iso-8859-8-i thing
     if ( $charset == "iso-8859-8-i" )
@@ -150,7 +150,7 @@ function charset_decode ($charset, $string, $force_decode=false, $save_html=fals
             // other charsets can be converted to utf-8 without loss.
             // and output string is smaller
             $string = recode_string($charset . "..utf-8",$string);
-            return ($save_html ? $strings : htmlspecialchars($string));
+            return ($save_html ? $string : htmlspecialchars($string));
         } else {
             $string = recode_string($charset . "..html",$string);
             // recode does not convert single quote, htmlspecialchars does.
@@ -166,7 +166,7 @@ function charset_decode ($charset, $string, $force_decode=false, $save_html=fals
     // iconv functions does not have html target and can be used only with utf-8
     if ( $use_php_iconv && $default_charset=='utf-8') {
         $string = iconv($charset,$default_charset,$string);
-        return ($save_html ? $strings : htmlspecialchars($string));
+        return ($save_html ? $string : htmlspecialchars($string));
     }
 
     // If we don't use recode and iconv, we'll do it old way.
@@ -261,6 +261,13 @@ function fixcharset($charset) {
      */
     $charset=preg_replace("/[-:.\/\\\]/",'_',$charset);
 
+    // OE ks_c_5601_1987 > cp949 
+    $charset=str_replace('ks_c_5601_1987','cp949',$charset);
+    // Moz x-euc-tw > euc-tw
+    $charset=str_replace('x_euc','euc',$charset);
+    // Moz x-windows-949 > cp949
+    $charset=str_replace('x_windows_','cp',$charset);
+
     // windows-125x and cp125x charsets
     $charset=str_replace('windows_','cp',$charset);