mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-09 12:54: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
|
06/07/2010
|
||||||
- create exception on recursive {extends} calls
|
- create exception on recursive {extends} calls
|
||||||
- fixed reported line number at "unexpected closing tag " exception
|
- fixed reported line number at "unexpected closing tag " exception
|
||||||
|
@@ -31,6 +31,8 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...',
|
|||||||
return '';
|
return '';
|
||||||
|
|
||||||
if (is_callable('mb_strlen')) {
|
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) {
|
if (mb_strlen($string) > $length) {
|
||||||
$length -= min($length, mb_strlen($etc));
|
$length -= min($length, mb_strlen($etc));
|
||||||
if (!$break_words && !$middle) {
|
if (!$break_words && !$middle) {
|
||||||
@@ -44,7 +46,9 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...',
|
|||||||
} else {
|
} else {
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
// $string has utf-8 no encoding
|
||||||
if (strlen($string) > $length) {
|
if (strlen($string) > $length) {
|
||||||
$length -= min($length, strlen($etc));
|
$length -= min($length, strlen($etc));
|
||||||
if (!$break_words && !$middle) {
|
if (!$break_words && !$middle) {
|
||||||
@@ -59,6 +63,5 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...',
|
|||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
Reference in New Issue
Block a user