Fix issue 785.
This commit is contained in:
parent
c0506c460d
commit
9bd5912884
@ -4,6 +4,9 @@
|
||||
|
||||
## Bugfixes
|
||||
|
||||
- Ensure that IDF does not break UTF-8 encoded strings when
|
||||
shortening them for view rendering (issue 785)
|
||||
|
||||
## Documentation
|
||||
|
||||
## Translations
|
||||
|
@ -506,12 +506,12 @@ function IDF_Views_Source_PrettySizeSimple($size)
|
||||
function IDF_Views_Source_ShortenString($string, $length)
|
||||
{
|
||||
$ellipse = "...";
|
||||
$length = max(strlen($ellipse) + 2, $length);
|
||||
$length = max(mb_strlen($ellipse) + 2, $length);
|
||||
$preflen = ceil($length / 10);
|
||||
|
||||
if (mb_strlen($string) < $length)
|
||||
return $string;
|
||||
|
||||
return substr($string, 0, $preflen).$ellipse.
|
||||
substr($string, -($length - $preflen - mb_strlen($ellipse)));
|
||||
return mb_substr($string, 0, $preflen).$ellipse.
|
||||
mb_substr($string, -($length - $preflen - mb_strlen($ellipse)));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user