mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-03 12:39:25 +01:00
fix not allways working transliteration of utf-8 to ascii
- using now mb_convert_encoding($str, 'html-entities', 'utf-8') if available - remove all non-ascii as a precausing after all conversions attempts
This commit is contained in:
parent
a25f8ece13
commit
b34fc0cfc2
@ -260,7 +260,7 @@ class Translation
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Translates a phrase according to the given user's language preference,
|
* Translates a phrase according to the given user's language preference,
|
||||||
* which may be different from the current user.
|
* which may be different from the current user.
|
||||||
*
|
*
|
||||||
* @param int $account_id
|
* @param int $account_id
|
||||||
* @param string $message
|
* @param string $message
|
||||||
@ -826,14 +826,23 @@ class Translation
|
|||||||
{
|
{
|
||||||
static $extra = array(
|
static $extra = array(
|
||||||
'ß' => 'ss',
|
'ß' => 'ss',
|
||||||
|
'̈' => 'e', // mb_convert_encoding return ̈ for all German umlauts
|
||||||
);
|
);
|
||||||
$entities = htmlentities($_str,ENT_QUOTES,self::charset());
|
if (function_exists('mb_convert_encoding'))
|
||||||
|
{
|
||||||
|
$entities = mb_convert_encoding($_str, 'html-entities', self::charset());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$entities = htmlentities($_str, ENT_QUOTES, self::charset());
|
||||||
|
}
|
||||||
|
|
||||||
$estr = str_replace(array_keys($extra),array_values($extra), $entities);
|
$estr = str_replace(array_keys($extra),array_values($extra), $entities);
|
||||||
$ustr = preg_replace('/&([aAuUoO])uml;/','\\1e', $estr); // replace german umlauts with the letter plus one 'e'
|
$ustr = preg_replace('/&([aAuUoO])uml;/','\\1e', $estr); // replace german umlauts with the letter plus one 'e'
|
||||||
$astr = preg_replace('/&([a-zA-Z])(grave|acute|circ|ring|cedil|tilde|slash|uml);/','\\1', $ustr); // remove all types of accents
|
$astr = preg_replace('/&([a-zA-Z])(grave|acute|circ|ring|cedil|tilde|slash|uml);/','\\1', $ustr); // remove all types of accents
|
||||||
|
|
||||||
return preg_replace('/&([a-zA-Z]+|#[0-9]+|);/','', $astr); // remove all other entities
|
return preg_replace('/[^\x20-\x7f]/', '', // remove all non-ascii
|
||||||
|
preg_replace('/&([a-zA-Z]+|#[0-9]+|);/','', $astr)); // remove all other entities
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user