src/Helpers/StringHelper.php
public static function truncate($string, $length, $suffix = '...', $encoding = null, $asHtml = false)
    {
        if ($encoding === null) {
            $encoding = \Reaction::$app ? \Reaction::$app->charset : 'UTF-8';
        }
        if ($asHtml) {
            return static::truncateHtml($string, $length, $suffix, $encoding);
        }

        if (mb_strlen($string, $encoding) > $length) {
            return rtrim(mb_substr($string, 0, $length, $encoding)) . $suffix;
        }

        return $string;
    }
public static function truncate($string, $length, $suffix = '...', $encoding = null, $asHtml = false)
    {
        if ($encoding === null) {
            $encoding = \Reaction::$app ? \Reaction::$app->charset : 'UTF-8';
        }
        if ($asHtml) {
            return static::truncateHtml($string, $length, $suffix, $encoding);
        }

        if (mb_strlen($string, $encoding) > $length) {
            return rtrim(mb_substr($string, 0, $length, $encoding)) . $suffix;
        }

        return $string;
    }
Truncates a string to the number of characters specified.

@param string $string The string to truncate.
@param int $length How many characters from original string to include into truncated string.
@param string $suffix String to append to the end of truncated string.
@param string $encoding The charset to use, defaults to charset currently used by application.
@param bool $asHtml Whether to treat the string being truncated as HTML and preserve proper HTML tags.
@return string the truncated string.