mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-07 03:44:26 +02:00
- bugfix the truncate modifier needs to check if the string is utf-8 encoded or not
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
07/07/2010
|
||||
- bugfix the truncate modifier needs to check if the string is utf-8 encoded or not
|
||||
|
||||
06/07/2010
|
||||
- create exception on recursive {extends} calls
|
||||
- fixed reported line number at "unexpected closing tag " exception
|
||||
|
@@ -31,6 +31,8 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...',
|
||||
return '';
|
||||
|
||||
if (is_callable('mb_strlen')) {
|
||||
if (mb_detect_encoding($text, 'UTF-8, ISO-8859-1') === 'UTF-8') {
|
||||
// $string has utf-8 encoding
|
||||
if (mb_strlen($string) > $length) {
|
||||
$length -= min($length, mb_strlen($etc));
|
||||
if (!$break_words && !$middle) {
|
||||
@@ -44,7 +46,9 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...',
|
||||
} else {
|
||||
return $string;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
// $string has utf-8 no encoding
|
||||
if (strlen($string) > $length) {
|
||||
$length -= min($length, strlen($etc));
|
||||
if (!$break_words && !$middle) {
|
||||
@@ -59,6 +63,5 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...',
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user