Simplified case statement. Suggestion from Thijs.
[squirrelmail.git] / functions / i18n.php
index 85e874c8aed9bd2b1b3865720c1cd1170816be24..d2415daf91c87c84b9d767ae9b27ea844f369d5e 100644 (file)
@@ -457,8 +457,8 @@ if ( file_exists( SM_PATH . 'locale/th_TH') ) {
 }
 if ( file_exists( SM_PATH . 'locale/lt_LT') ) {
     $languages['lt_LT']['NAME']    = 'Lithuanian';
-    $languages['lt_LT']['CHARSET'] = 'windows-1257';
-    $languages['lt_LT']['LOCALE'] = 'lt_LT.CP1257';
+    $languages['lt_LT']['CHARSET'] = 'iso-8859-4';
+    $languages['lt_LT']['LOCALE'] = 'lt_LT.ISO-8859-4';
     $languages['lt']['ALIAS'] = 'lt_LT';
 }
 if ( file_exists( SM_PATH . 'locale/sl_SI') ) {
@@ -697,4 +697,46 @@ function korean_charset_xtra() {
     return $ret;
 }
 
+/* 
+ * This function can be used to replace non-braking space symbols 
+ * that are inserted in forms by some browsers instead of normal 
+ * space symbol.
+ */
+function cleanup_nbsp($string,$charset) {
+
+  // reduce number of case statements
+  if (stristr('iso-8859-',substr($charset,0,9))){
+    $output_charset="iso-8859-x";
+  }
+  if (stristr('windows-125',substr($charset,0,11))){
+    $output_charset="cp125x";
+  }
+  if (stristr('koi8',substr($charset,0,4))){
+    $output_charset="koi8-x";
+  }
+  if (! isset($output_charset)){
+    $output_charset=strtolower($charset);
+  }
+
+// where is non-braking space symbol
+switch($output_charset):
+ case "iso-8859-x":
+ case "cp125x":
+ case "iso-2022-jp":
+  $nbsp="\xA0";
+  break;
+ case "koi8-x":
+   $nbsp="\x9A";
+   break;
+ case "utf-8":
+   $nbsp="\xC2\xA0";
+   break;
+ default:
+   // don't change string if charset is unmatched
+   return $string;
+endswitch;
+
+// return space instead of non-braking space. 
+ return str_replace($nbsp,' ',$string);
+}
 ?>
\ No newline at end of file