summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-02-13 02:04:07 +0100
committerAndrey Andreev <narf@devilix.net>2014-02-13 02:04:07 +0100
commitdbcd12d48024fc70a464e96f9e90bf1f341d0a11 (patch)
treea4ce0c245265129e456daa0bcfd33f459521cc7b /system
parent3fd1b384273b7b6d56950bbad3e1fac18f5f82e4 (diff)
parent2c30bd72b46cfdd36878273c5a8d843c7e056d42 (diff)
Merge pull request #2610 from mjnaderi/patch-1
character_limiter now works correct for UTF-8 strings
Diffstat (limited to 'system')
-rw-r--r--system/helpers/text_helper.php8
1 files changed, 4 insertions, 4 deletions
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 206ce5559..45e8ae760 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -85,7 +85,7 @@ if ( ! function_exists('character_limiter'))
*/
function character_limiter($str, $n = 500, $end_char = '&#8230;')
{
- if (strlen($str) < $n)
+ if (mb_strlen($str) < $n)
{
return $str;
}
@@ -93,7 +93,7 @@ if ( ! function_exists('character_limiter'))
// a bit complicated, but faster than preg_replace with \s+
$str = preg_replace('/ {2,}/', ' ', str_replace(array("\r", "\n", "\t", "\x0B", "\x0C"), ' ', $str));
- if (strlen($str) <= $n)
+ if (mb_strlen($str) <= $n)
{
return $str;
}
@@ -103,10 +103,10 @@ if ( ! function_exists('character_limiter'))
{
$out .= $val.' ';
- if (strlen($out) >= $n)
+ if (mb_strlen($out) >= $n)
{
$out = trim($out);
- return (strlen($out) === strlen($str)) ? $out : $out.$end_char;
+ return (mb_strlen($out) === mb_strlen($str)) ? $out : $out.$end_char;
}
}
}