if encoding function can't find charset, it does us-ascii encoding.
authortokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 27 Aug 2004 11:54:17 +0000 (11:54 +0000)
committertokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 27 Aug 2004 11:54:17 +0000 (11:54 +0000)
$enable_loosy_encoding option allows to use charset conversion in compose,
when output charset does not provide full support of symbols used in input
charset. (for example. utf-8 -> iso-8859-1). Provides solution for bug.806698

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@7968 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/i18n.php

index 58ab06ce95c9aff4cdc7c685692b022961c289ef..6766968a6baf4ec1613dee7b8f37c9ec24a21f87 100644 (file)
@@ -119,16 +119,17 @@ function charset_encode($string,$charset,$htmlencode=true) {
 
   // Undo html special chars
   if (! $htmlencode ) {
-     $string = str_replace(array('&amp;','&gt;','&lt;','&quot;'),array('&','>','<','"'),$string);
+      $string = str_replace(array('&amp;','&gt;','&lt;','&quot;'),array('&','>','<','"'),$string);
   }
 
   $encode=fixcharset($charset);
   $encodefile=SM_PATH . 'functions/encode/' . $encode . '.php';
   if (file_exists($encodefile)) {
-    include_once($encodefile);
-    $ret = call_user_func('charset_encode_'.$encode, $string);
+      include_once($encodefile);
+      $ret = call_user_func('charset_encode_'.$encode, $string);
   } else {
-    $ret = $string;
+      include_once(SM_PATH . 'functions/encode/us_ascii.php');
+      $ret = charset_encode_us_ascii($string);
   }
   return( $ret );
 }
@@ -145,9 +146,9 @@ function charset_encode($string,$charset,$htmlencode=true) {
  * @return string converted string
  */
 function charset_convert($in_charset,$string,$out_charset,$htmlencode=true) {
-  $string=charset_decode($in_charset,$string);
-  $string=charset_encode($string,$out_charset,$htmlencode);
-  return $string;
+    $string=charset_decode($in_charset,$string);
+    $string=charset_encode($string,$out_charset,$htmlencode);
+    return $string;
 }
 
 /**
@@ -1147,7 +1148,10 @@ endswitch;
  * @return bool is it possible to convert to user's charset
  */
 function is_conversion_safe($input_charset) {
-  global $languages, $sm_notAlias, $default_charset;
+  global $languages, $sm_notAlias, $default_charset, $enable_loosy_encoding;
+
+    if (isset($enable_loosy_encoding) && $enable_loosy_encoding )
+       return true;
 
  // convert to lower case
  $input_charset = strtolower($input_charset);