Fixed issue with UTF-8 2-byte characters

Characters were being split up and causing invalid sequences when using
`substr()`. Went ahead and updated to use `mb_strcut()` and forcing the
character encoding to UTF-8. I think the plan down the road will be to set the
internal encoding to UTF-8 but I am not currently sure how that could effect
the rest of the system (perhaps it won't). Closes #39
This commit is contained in:
Joshua Sherman 2014-01-26 15:09:16 -05:00
parent 782bad5c02
commit 0810302e4f
2 changed files with 3 additions and 3 deletions

View file

@ -225,11 +225,11 @@ class String
{
if ($hover == true)
{
$string = '<span title="' . $string . '">' . substr($string, 0, $length) . '&hellip;</span>';
$string = '<span title="' . $string . '">' . mb_strcut($string, 0, $length, 'UTF-8') . '&hellip;</span>';
}
else
{
$string = substr($string, 0, $length) . '...';
$string = mb_strcut($string, 0, $length, 'UTF-8') . '&hellip;';
}
}