* functions are not available. Scripts in functions/ directory should not
* setup anything when they are loaded.
*
- * @copyright 1999-2019 The SquirrelMail Project Team
+ * @copyright 1999-2021 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
* @package squirrelmail
}
/**
- * Converts string from given charset to charset, that can be displayed by user translation.
+ * Converts a string from the given $charset to a character set that
+ * can be displayed by the current user interface language (translation)
*
- * Function by default returns html encoded strings, if translation uses different encoding.
+ * Function by default returns html encoded strings if translation uses
+ * different encoding.
* If Japanese translation is used - function returns string converted to euc-jp
* If iconv or recode functions are enabled and translation uses utf-8 - function returns utf-8 encoded string.
* If $charset is not supported - function returns unconverted string.
*
* sanitizing of html tags is also done by this function.
*
- * @param string $charset
+ * @param string $charset The charset of the incoming string
* @param string $string Text to be decoded
* @param boolean $force_decode converts string to html without $charset!=$default_charset check.
* Argument is available since 1.4.5 and 1.5.1.
// Don't do conversion if charset is the same.
if ( ! $force_decode && $charset == strtolower($default_charset) )
- return ($save_html ? $string : sm_encode_html_special_chars($string));
+ return ($save_html ? $string : sm_encode_html_special_chars($string, ENT_COMPAT, $charset));
// catch iso-8859-8-i thing
if ( $charset == "iso-8859-8-i" )
// 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 ? $string : sm_encode_html_special_chars($string));
+ return ($save_html ? $string : sm_encode_html_special_chars($string, ENT_COMPAT, $charset));
} else {
$string = recode_string($charset . "..html",$string);
// recode does not convert single quote, sm_encode_html_special_chars does.
// 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 ? $string : sm_encode_html_special_chars($string));
+ return ($save_html ? $string : sm_encode_html_special_chars($string, ENT_COMPAT, $charset));
}
// If we don't use recode and iconv, we'll do it old way.
/* All HTML special characters are 7 bit and can be replaced first */
- if (! $save_html) $string = sm_encode_html_special_chars ($string);
+ if (! $save_html) $string = sm_encode_html_special_chars($string, ENT_COMPAT, $charset);
/* controls cpu and memory intensive decoding cycles */
if (! isset($aggressive_decoding) || $aggressive_decoding=="" ) {