summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/helpers/inflector_helper.php17
-rw-r--r--system/helpers/text_helper.php16
-rw-r--r--user_guide_src/source/changelog.rst11
3 files changed, 25 insertions, 19 deletions
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index 210d0fdfd..b44594e2a 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -188,7 +188,7 @@ if ( ! function_exists('underscore'))
*/
function underscore($str)
{
- return preg_replace('/[\s]+/', '_', strtolower(trim($str)));
+ return preg_replace('/[\s]+/', '_', trim(MB_ENABLED ? mb_strtolower($str) : strtolower($str)));
}
}
@@ -207,7 +207,7 @@ if ( ! function_exists('humanize'))
*/
function humanize($str, $separator = '_')
{
- return ucwords(preg_replace('/['.$separator.']+/', ' ', strtolower(trim($str))));
+ return ucwords(preg_replace('/['.$separator.']+/', ' ', trim(MB_ENABLED ? mb_strtolower($str) : strtolower($str))));
}
}
@@ -223,12 +223,13 @@ if ( ! function_exists('is_countable'))
*/
function is_countable($word)
{
- return ! in_array(strtolower($word),
- array(
- 'equipment', 'information', 'rice', 'money',
- 'species', 'series', 'fish', 'meta'
- )
- );
+ return ! in_array(
+ strtolower($word),
+ array(
+ 'equipment', 'information', 'rice', 'money',
+ 'species', 'series', 'fish', 'meta'
+ )
+ );
}
}
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;
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index ce84b7f54..16c30b795 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -90,7 +90,8 @@ Release Date: Not Released
- :doc:`Inflector Helper <helpers/inflector_helper>` changes include:
- Changed :func:`humanize()` to allow passing an input separator as its second parameter.
- - Refactored :func:`plural()` and :func:`singular()` to avoid double pluralization and support more words.
+ - Changed :func:`humanize()` and :func:`underscore()` to utilize `mbstring <http://php.net/mbstring>`_, if available.
+ - Changed :func:`plural()` and :func:`singular()` to avoid double pluralization and support more words.
- :doc:`Download Helper <helpers/download_helper>` changes include:
@@ -132,10 +133,14 @@ Release Date: Not Released
- Added *colors* configuration to allow customization for the *background*, *border*, *text* and *grid* colors.
- Added *filename* to the returned array elements.
+ - :doc:`Text Helper <helpers/text_helper>` changes include:
+
+ - Changed the default tag for use in :func:`highlight_phrase()` to ``<mark>`` (formerly ``<strong>``).
+ - Changed :func:`character_limiter()`, :func:`word_wrap()` and :func:`ellipsize()` to utilize `mbstring <http://php.net/mbstring>`_ or `iconv <http://php.net/iconv>`_, if available.
+
- :doc:`Directory Helper <helpers/directory_helper>` :func:`directory_map()` will now append ``DIRECTORY_SEPARATOR`` to directory names in the returned array.
- :doc:`Array Helper <helpers/array_helper>` :func:`element()` and :func:`elements()` now return NULL instead of FALSE when the required elements don't exist.
- :doc:`Language Helper <helpers/language_helper>` :func:`lang()` now accepts an optional list of additional HTML attributes.
- - Changed the default tag for use in :doc:`Text Helper <helpers/text_helper>` :func:`highlight_phrase()` to ``<mark>`` (formerly ``<strong>``).
- Deprecated the :doc:`Email Helper <helpers/email_helper>` as its ``valid_email()``, ``send_email()`` functions are now only aliases for PHP native functions ``filter_var()`` and ``mail()`` respectively.
- Database
@@ -499,7 +504,7 @@ Release Date: Not Released
- ``UTF8_ENABLED`` now requires only one of `Multibyte String <http://php.net/mbstring>`_ or `iconv <http://php.net/iconv>`_ to be available instead of both.
- Changed method ``clean_string()`` to utilize ``mb_convert_encoding()`` if it is available but ``iconv()`` is not.
- - Added compatibility layers for PHP's `Multibyte string <http://php.net/mbstring>`_ (limited support) and `Password Hashing <http://php.net/password>` extensions.
+ - Added compatibility layers for PHP's `mbstring <http://php.net/mbstring>`_ (limited support) and `password <http://php.net/password>`_ extensions.
- Removed ``CI_CORE`` boolean constant from *CodeIgniter.php* (no longer Reactor and Core versions).
- Log Library will now try to create the **log_path** directory if it doesn't exist.
- Added support for HTTP-Only cookies with new config option *cookie_httponly* (default FALSE).