mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
- Treat system messages as ISO-8859-1 just like PHP does it
git-svn-id: file:///svn/phpbb/trunk@6848 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
5d91d46384
commit
f3b5143682
1 changed files with 9 additions and 14 deletions
|
@ -1129,26 +1129,21 @@ function utf8_htmlspecialchars(&$value)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trying to convert returned system message to utf8
|
* Trying to convert returned system message to utf8
|
||||||
|
*
|
||||||
|
* PHP assumes such messages are ISO-8859-1 so we'll do that too
|
||||||
|
* and if it breaks messages we'll blame it on them ;-)
|
||||||
|
*/
|
||||||
function utf8_convert_message($message)
|
function utf8_convert_message($message)
|
||||||
{
|
{
|
||||||
// First of all check if conversion is possible/needed
|
// First of all check if conversion is neded at all, as there is no point
|
||||||
if (empty($_SERVER['HTTP_ACCEPT_CHARSET']) || !preg_match('/[\x80-\xFF]/', $message))
|
// in converting ASCII messages from ISO-8859-1 to UTF-8
|
||||||
{
|
if (!preg_match('/[\x80-\xFF]/', $message))
|
||||||
return htmlspecialchars($message);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Guess the encoding. Because it is used for system messages we check the system/server.
|
|
||||||
$encoding = explode(',', $_SERVER['HTTP_ACCEPT_CHARSET']);
|
|
||||||
$encoding = (empty($encoding)) ? array() : explode(';', $encoding[0]);
|
|
||||||
$encoding = (empty($encoding)) ? false : trim(strtolower($encoding[0]));
|
|
||||||
|
|
||||||
if (empty($encoding) || $encoding == 'utf-8')
|
|
||||||
{
|
{
|
||||||
return utf8_htmlspecialchars($message);
|
return utf8_htmlspecialchars($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return utf8_htmlspecialchars(utf8_recode($message, $encoding));
|
// else we need to convert some part of the message
|
||||||
|
return utf8_htmlspecialchars(utf8_recode($message, 'ISO-8859-1'));
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue