From: tokul Date: Fri, 27 Aug 2004 11:54:17 +0000 (+0000) Subject: if encoding function can't find charset, it does us-ascii encoding. X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=33991968233a93217be237585a2265d1700883b8 if encoding function can't find charset, it does us-ascii encoding. $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 --- diff --git a/functions/i18n.php b/functions/i18n.php index 58ab06ce..6766968a 100644 --- a/functions/i18n.php +++ b/functions/i18n.php @@ -119,16 +119,17 @@ function charset_encode($string,$charset,$htmlencode=true) { // Undo html special chars if (! $htmlencode ) { - $string = str_replace(array('&','>','<','"'),array('&','>','<','"'),$string); + $string = str_replace(array('&','>','<','"'),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);