projects
/
squirrelmail.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
moving main color tags to css
[squirrelmail.git]
/
functions
/
i18n.php
diff --git
a/functions/i18n.php
b/functions/i18n.php
index 5b33204d07591edfe91aeacebcd1c23f4b327db4..9f01614429a56f7f0c29293b54de4adab0d78d45 100644
(file)
--- a/
functions/i18n.php
+++ b/
functions/i18n.php
@@
-1,16
+1,16
@@
<?php
<?php
+
/**
* SquirrelMail internationalization functions
*
/**
* SquirrelMail internationalization functions
*
- * Copyright (c) 1999-2005 The SquirrelMail Project Team
- * Licensed under the GNU GPL. For full terms see the file COPYING.
- *
* This file contains variuos functions that are needed to do
* internationalization of SquirrelMail.
*
* Internally the output character set is used. Other characters are
* encoded using Unicode entities according to HTML 4.0.
*
* This file contains variuos functions that are needed to do
* internationalization of SquirrelMail.
*
* Internally the output character set is used. Other characters are
* encoded using Unicode entities according to HTML 4.0.
*
+ * @copyright © 1999-2005 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
* @package squirrelmail
* @subpackage i18n
* @version $Id$
* @package squirrelmail
* @subpackage i18n
@@
-109,9
+109,11
@@
function sq_setlocale($category,$locale) {
* @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.5.1 and 1.4.5.
* @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.5.1 and 1.4.5.
+ * @param boolean $save_html disables htmlspecialchars() in order to preserve
+ * html formating. Use with care. Available since 1.5.1
* @return string decoded string
*/
* @return string decoded string
*/
-function charset_decode ($charset, $string, $force_decode=false) {
+function charset_decode ($charset, $string, $force_decode=false
, $save_html=false
) {
global $languages, $squirrelmail_language, $default_charset;
global $use_php_recode, $use_php_iconv, $aggressive_decoding;
global $languages, $squirrelmail_language, $default_charset;
global $use_php_recode, $use_php_iconv, $aggressive_decoding;
@@
-132,7
+134,7
@@
function charset_decode ($charset, $string, $force_decode=false) {
// Don't do conversion if charset is the same.
if ( ! $force_decode && $charset == strtolower($default_charset) )
// Don't do conversion if charset is the same.
if ( ! $force_decode && $charset == strtolower($default_charset) )
- return
htmlspecialchars($string
);
+ return
($save_html ? $string : htmlspecialchars($string)
);
// catch iso-8859-8-i thing
if ( $charset == "iso-8859-8-i" )
// catch iso-8859-8-i thing
if ( $charset == "iso-8859-8-i" )
@@
-148,11
+150,15
@@
function charset_decode ($charset, $string, $force_decode=false) {
// other charsets can be converted to utf-8 without loss.
// and output string is smaller
$string = recode_string($charset . "..utf-8",$string);
// other charsets can be converted to utf-8 without loss.
// and output string is smaller
$string = recode_string($charset . "..utf-8",$string);
- return
htmlspecialchars($string
);
+ return
($save_html ? $string : htmlspecialchars($string)
);
} else {
$string = recode_string($charset . "..html",$string);
// recode does not convert single quote, htmlspecialchars does.
$string = str_replace("'", ''', $string);
} else {
$string = recode_string($charset . "..html",$string);
// recode does not convert single quote, htmlspecialchars does.
$string = str_replace("'", ''', $string);
+ // undo html specialchars
+ if ($save_html)
+ $string=str_replace(array('&','"','<','>'),
+ array('&','"','<','>'),$string);
return $string;
}
}
return $string;
}
}
@@
-160,14
+166,13
@@
function charset_decode ($charset, $string, $force_decode=false) {
// 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);
// 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
htmlspecialchars($string
);
+ return
($save_html ? $string : htmlspecialchars($string)
);
}
// 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 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 */
-
- $string = htmlspecialchars ($string);
+ if (! $save_html) $string = htmlspecialchars ($string);
/* controls cpu and memory intensive decoding cycles */
if (! isset($aggressive_decoding) || $aggressive_decoding=="" ) {
/* controls cpu and memory intensive decoding cycles */
if (! isset($aggressive_decoding) || $aggressive_decoding=="" ) {
@@
-177,7
+182,8
@@
function charset_decode ($charset, $string, $force_decode=false) {
$decodefile=SM_PATH . 'functions/decode/' . $decode . '.php';
if (file_exists($decodefile)) {
include_once($decodefile);
$decodefile=SM_PATH . 'functions/decode/' . $decode . '.php';
if (file_exists($decodefile)) {
include_once($decodefile);
- $ret = call_user_func('charset_decode_'.$decode, $string);
+ // send $save_html argument to decoding function. needed for iso-2022-xx decoding.
+ $ret = call_user_func('charset_decode_'.$decode, $string, $save_html);
} else {
$ret = $string;
}
} else {
$ret = $string;
}
@@
-255,6
+261,13
@@
function fixcharset($charset) {
*/
$charset=preg_replace("/[-:.\/\\\]/",'_',$charset);
*/
$charset=preg_replace("/[-:.\/\\\]/",'_',$charset);
+ // OE ks_c_5601_1987 > cp949
+ $charset=str_replace('ks_c_5601_1987','cp949',$charset);
+ // Moz x-euc-tw > euc-tw
+ $charset=str_replace('x_euc','euc',$charset);
+ // Moz x-windows-949 > cp949
+ $charset=str_replace('x_windows_','cp',$charset);
+
// windows-125x and cp125x charsets
$charset=str_replace('windows_','cp',$charset);
// windows-125x and cp125x charsets
$charset=str_replace('windows_','cp',$charset);