/* Decodes a string to the internal encoding from the given charset */
function charset_decode ($charset, $string) {
global $languages, $squirrelmail_language, $default_charset;
+ global $use_php_recode, $use_php_iconv, $agresive_decoding;
if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
set_my_charset();
// Variables that allow to use functions without function_exist() calls
- $use_php_recode=false;
- $use_php_iconv=false;
+ if (! isset($use_php_recode) || $use_php_recode=="" ) {
+ $use_php_recode=false; }
+ if (! isset($use_php_iconv) || $use_php_iconv=="" ) {
+ $use_php_iconv=false; }
// Don't do conversion if charset is the same.
if ( $charset == strtolower($default_charset) )
$string = htmlspecialchars ($string);
/* controls cpu and memory intensive decoding cycles */
- $agresive_decoding = false;
+ if (! isset($agresive_decoding) || $agresive_decoding=="" ) {
+ $agresive_decoding=false; }
if (ereg('iso-8859-([[:digit:]]+)', $charset, $res)) {
if ($res[1] == '1') {
} else if ($charset == 'ibm866') {
include_once(SM_PATH . 'functions/decode/cp866.php');
$ret = charset_decode_cp866 ($string);
+ } else if ($charset == 'iso-ir-111') {
+ include_once(SM_PATH . 'functions/decode/iso-ir-111.php');
+ $ret = charset_decode_iso_ir_111 ($string);
} else if ($charset == 'tis-620') {
include_once(SM_PATH . 'functions/decode/tis620.php');
$ret = charset_decode_tis620 ($string);
$languages['bg_BG']['CHARSET'] = 'windows-1251';
$languages['bg']['ALIAS'] = 'bg_BG';
}
+/*
if ( file_exists( SM_PATH . 'locale/uk_UA') ) {
$languages['uk_UA']['NAME'] = 'Ukrainian';
$languages['uk_UA']['CHARSET'] = 'koi8-u';
$languages['uk']['ALIAS'] = 'uk_UA';
}
+*/
if ( file_exists( SM_PATH . 'locale/cy_GB') ) {
$languages['cy_GB']['NAME'] = 'Welsh';
$languages['cy_GB']['ALTNAME'] = 'Cymraeg';
$languages['cy_GB']['CHARSET'] = 'iso-8859-1';
$languages['cy']['ALIAS'] = 'cy_GB';
}
+/*
if ( file_exists( SM_PATH . 'locale/vi_VN') ) {
$languages['vi_VN']['NAME'] = 'Vietnamese';
$languages['vi_VN']['CHARSET'] = 'utf-8';
$languages['vi']['ALIAS'] = 'vi_VN';
}
+*/
// Right to left languages
if ( file_exists( SM_PATH . 'locale/ar') ) {
$languages['ar']['NAME'] = 'Arabic';
// return space instead of non-braking space.
return str_replace($nbsp,' ',$string);
}
+
+function is_conversion_safe($input_charset) {
+ global $languages, $sm_notAlias, $default_charset;
+
+ // convert to lower case
+ $input_charset = strtolower($input_charset);
+
+ // Is user's locale Unicode based ?
+ if ( $default_charset == "utf-8" ) {
+ return true;
+ }
+
+ // Charsets that are similar
+switch ($default_charset):
+case "windows-1251":
+ if ( $input_charset == "iso-8859-5" ||
+ $input_charset == "koi8-r" ||
+ $input_charset == "koi8-u" ) {
+ return true;
+ } else {
+ return false;
+ }
+case "windows-1257":
+ if ( $input_charset == "iso-8859-13" ||
+ $input_charset == "iso-8859-4" ) {
+ return true;
+ } else {
+ return false;
+ }
+case "iso-8859-4":
+ if ( $input_charset == "iso-8859-13" ||
+ $input_charset == "windows-1257" ) {
+ return true;
+ } else {
+ return false;
+ }
+case "iso-8859-5":
+ if ( $input_charset == "windows-1251" ||
+ $input_charset == "koi8-r" ||
+ $input_charset == "koi8-u" ) {
+ return true;
+ } else {
+ return false;
+ }
+case "iso-8859-13":
+ if ( $input_charset == "iso-8859-4" ||
+ $input_charset == "windows-1257" ) {
+ return true;
+ } else {
+ return false;
+ }
+case "koi8-r":
+ if ( $input_charset == "windows-1251" ||
+ $input_charset == "iso-8859-5" ||
+ $input_charset == "koi8-u" ) {
+ return true;
+ } else {
+ return false;
+ }
+case "koi8-u":
+ if ( $input_charset == "windows-1251" ||
+ $input_charset == "iso-8859-5" ||
+ $input_charset == "koi8-r" ) {
+ return true;
+ } else {
+ return false;
+ }
+default:
+ return false;
+endswitch;
+}
?>