$ret = charset_decode_iso_8859_1 ($string);
} else if ($res[1] == '2') {
$ret = charset_decode_iso_8859_2 ($string);
+ } else if ($res[1] == '4') {
+ $ret = charset_decode_iso_8859_4 ($string);
} else if ($res[1] == '7') {
$ret = charset_decode_iso_8859_7 ($string);
+ } else if ($res[1] == '13') {
+ $ret = charset_decode_iso_8859_13 ($string);
} else if ($res[1] == '15') {
$ret = charset_decode_iso_8859_15 ($string);
} else {
return $string;
}
+/*
+ iso-8859-4 is Baltic codeset used in some email clients
+ instead of iso-8859-13 in Lithuania
+ only Lithuanian charactes are added.
+*/
+
+function charset_decode_iso_8859_4 ($string) {
+ // latin capital a with ogonek
+ $string = str_replace ("\241", 'Ą', $string);
+ // latin capital c with caron
+ $string = str_replace ("\310", 'Č', $string);
+ // latin capital e with ogonek
+ $string = str_replace ("\312", 'Ę', $string);
+ // latin capital e with dot above
+ $string = str_replace ("\314", 'Ė', $string);
+ // latin capital i with ogonek
+ $string = str_replace ("\307", 'Į', $string);
+ // latin capital s with caron
+ $string = str_replace ("\251", 'Š', $string);
+ // latin capital u with ogonek
+ $string = str_replace ("\331", 'Ų', $string);
+ // latin capital u with macron
+ $string = str_replace ("\336", 'Ū', $string);
+ // latin capital z with caron
+ $string = str_replace ("\256", 'Ž', $string);
+ // latin small a with ogonek
+ $string = str_replace ("\261", 'ą', $string);
+ // latin small c with caron
+ $string = str_replace ("\350", 'č', $string);
+ // latin small e with ogonek
+ $string = str_replace ("\352", 'ę', $string);
+ // latin small e with dot above
+ $string = str_replace ("\354", 'ė', $string);
+ // latin small i with ogonek
+ $string = str_replace ("\347", 'į', $string);
+ // latin small s with caron
+ $string = str_replace ("\271", 'š', $string);
+ // latin small u with ogonek
+ $string = str_replace ("\371", 'ų', $string);
+ // latin small u with macron
+ $string = str_replace ("\376", 'ū', $string);
+ // latin small z with caron
+ $string = str_replace ("\276", 'ž', $string);
+
+ return (charset_decode_iso_8859_1($string));
+}
+
/* iso-8859-7 is Greek. */
function charset_decode_iso_8859_7 ($string) {
global $default_charset;
* ISO-8859-7 characters from 11/04 (0xB4) to 11/06 (0xB6)
* These are Unicode 900-902
*/
- $string = preg_replace("/([\264-\266])/","'&#' . (ord(\\1)+720)",$string);
+ $string = preg_replace("/([\264-\266])/e","'&#' . (ord('\\1')+720);",$string);
/* 11/07 (0xB7) Middle dot is the same in iso-8859-1 */
$string = str_replace("\267", '·', $string);
* ISO-8859-7 characters from 11/08 (0xB8) to 11/10 (0xBA)
* These are Unicode 900-902
*/
- $string = preg_replace("/([\270-\272])/","'&#' . (ord(\\1)+720)",$string);
+ $string = preg_replace("/([\270-\272])/e","'&#' . (ord('\\1')+720);",$string);
/*
* 11/11 (0xBB) Right angle quotation mark is the same as in
$string = str_replace("\273", '»', $string);
/* And now the rest of the charset */
- $string = preg_replace("/([\274-\376])/","'&#' . (ord(\\1)+720)",$string);
+ $string = preg_replace("/([\274-\376])/e","'&#'.(ord('\\1')+720);",$string);
return $string;
}
+/*
+ iso-8859-13 codeset used in Lithuania
+ only Lithuanian charactes are added.
+*/
+
+function charset_decode_iso_8859_13 ($string) {
+ // latin capital a with ogonek
+ $string = str_replace ("\300", 'Ą', $string);
+ // latin capital c with caron
+ $string = str_replace ("\310", 'Č', $string);
+ // latin capital e with ogonek
+ $string = str_replace ("\306", 'Ę', $string);
+ // latin capital e with dot above
+ $string = str_replace ("\313", 'Ė', $string);
+ // latin capital i with ogonek
+ $string = str_replace ("\301", 'Į', $string);
+ // latin capital s with caron
+ $string = str_replace ("\320", 'Š', $string);
+ // latin capital u with ogonek
+ $string = str_replace ("\330", 'Ų', $string);
+ // latin capital u with macron
+ $string = str_replace ("\333", 'Ū', $string);
+ // latin capital z with caron
+ $string = str_replace ("\336", 'Ž', $string);
+ // latin small a with ogonek
+ $string = str_replace ("\340", 'ą', $string);
+ // latin small c with caron
+ $string = str_replace ("\350", 'č', $string);
+ // latin small e with ogonek
+ $string = str_replace ("\346", 'ę', $string);
+ // latin small e with dot above
+ $string = str_replace ("\353", 'ė', $string);
+ // latin small i with ogonek
+ $string = str_replace ("\341", 'į', $string);
+ // latin small s with caron
+ $string = str_replace ("\360", 'š', $string);
+ // latin small u with ogonek
+ $string = str_replace ("\370", 'ų', $string);
+ // latin small u with macron
+ $string = str_replace ("\373", 'ū', $string);
+ // latin small z with caron
+ $string = str_replace ("\376", 'ž', $string);
+
+ return (charset_decode_iso_8859_1($string));
+}
+
/*
* iso-8859-15 is Latin 9 and has very much the same use as Latin 1
* but has the Euro symbol and some characters needed for French.
function set_up_language($sm_language, $do_search = false) {
static $SetupAlready = 0;
- global $HTTP_ACCEPT_LANGUAGE, $use_gettext, $languages,
+ global $use_gettext, $languages,
$squirrelmail_language, $squirrelmail_default_language,
$sm_notAlias;
}
$SetupAlready = TRUE;
- if ($do_search && ! $sm_language && isset($HTTP_ACCEPT_LANGUAGE)) {
- $sm_language = substr($HTTP_ACCEPT_LANGUAGE, 0, 2);
+ if ($do_search && ! $sm_language && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
+ $sm_language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
}
if (!$sm_language && isset($squirrelmail_default_language)) {
/* If we can fake gettext, try that */
elseif ($gettext_flags == 0) {
$use_gettext = true;
- include_once('../functions/gettext.php');
+ include_once(SM_PATH . 'functions/gettext.php');
} else {
/* Uh-ho. A weird install */
if (! $gettext_flags & 1) {
$ret = mb_strimwidth($ret, 0, $width, '...');
break;
case 'encodeheader':
- $ret = mb_encode_mimeheader($ret);
+ $result = '';
+ if (strlen($ret) > 0) {
+ $tmpstr = mb_substr($ret, 0, 1);
+ $prevcsize = strlen($tmpstr);
+ for ($i = 1; $i < mb_strlen($ret); $i++) {
+ $tmp = mb_substr($ret, $i, 1);
+ if (strlen($tmp) == $prevcsize) {
+ $tmpstr .= $tmp;
+ } else {
+ if ($prevcsize == 1) {
+ $result .= $tmpstr;
+ } else {
+ $result .= mb_encode_mimeheader($tmpstr);
+ }
+ $tmpstr = $tmp;
+ $prevcsize = strlen($tmp);
+ }
+ }
+ if (strlen($tmpstr)) {
+ if (strlen(mb_substr($tmpstr, 0, 1)) == 1)
+ $result .= $tmpstr;
+ else
+ $result .= mb_encode_mimeheader($tmpstr);
+ }
+ }
+ $ret = $result;
+ //$ret = mb_encode_mimeheader($ret);
break;
case 'decodeheader':
$ret = str_replace("\t", "", $ret);
return $ret;
}
-?>
\ No newline at end of file
+?>