diff options
author | Andrey Andreev <narf@devilix.net> | 2014-02-13 02:28:00 +0100 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2014-02-13 02:28:00 +0100 |
commit | 6ce4746474ddf050f7f4df61b7a22b7f5854d533 (patch) | |
tree | 42d6cbca7b03c4dca040b42768c779def90217fb /system/helpers/text_helper.php | |
parent | dbcd12d48024fc70a464e96f9e90bf1f341d0a11 (diff) |
Update Text and Inflector helpers to utilize mbstring, if available
Text: word_wrap(), ellipsize()
Inflector: humanize(), underscore() (rel #2855)
Diffstat (limited to 'system/helpers/text_helper.php')
-rw-r--r-- | system/helpers/text_helper.php | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index 45e8ae760..76e1735b5 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -445,14 +445,14 @@ if ( ! function_exists('word_wrap')) { // Is the line within the allowed character count? // If so we'll join it to the output and continue - if (strlen($line) <= $charlim) + if (mb_strlen($line) <= $charlim) { $output .= $line."\n"; continue; } $temp = ''; - while ((strlen($line)) > $charlim) + while (mb_strlen($line) > $charlim) { // If the over-length word is a URL we won't wrap it if (preg_match('!\[url.+\]|://|wwww.!', $line)) @@ -461,8 +461,8 @@ if ( ! function_exists('word_wrap')) } // Trim the word down - $temp .= substr($line, 0, $charlim - 1); - $line = substr($line, $charlim - 1); + $temp .= mb_substr($line, 0, $charlim - 1); + $line = mb_substr($line, $charlim - 1); } // If $temp contains data it means we had to split up an over-length @@ -512,21 +512,21 @@ if ( ! function_exists('ellipsize')) $str = trim(strip_tags($str)); // Is the string long enough to ellipsize? - if (strlen($str) <= $max_length) + if (mb_strlen($str) <= $max_length) { return $str; } - $beg = substr($str, 0, floor($max_length * $position)); + $beg = mb_substr($str, 0, floor($max_length * $position)); $position = ($position > 1) ? 1 : $position; if ($position === 1) { - $end = substr($str, 0, -($max_length - strlen($beg))); + $end = mb_substr($str, 0, -($max_length - mb_strlen($beg))); } else { - $end = substr($str, -($max_length - strlen($beg))); + $end = mb_substr($str, -($max_length - mb_strlen($beg))); } return $beg.$ellipsis.$end; |