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