From bb3edf12d0ca82c62f7b7d570108375ec4379749 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 20 Feb 2014 17:51:41 +0200 Subject: CI_Utf8-related changes - Give priority to mb_convert_encoding() over iconv() in clean_string() (partially fixes #261) - Add more proper unit tests --- system/core/Utf8.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'system/core/Utf8.php') diff --git a/system/core/Utf8.php b/system/core/Utf8.php index c789a7ba4..9a92efe68 100644 --- a/system/core/Utf8.php +++ b/system/core/Utf8.php @@ -80,13 +80,13 @@ class CI_Utf8 { { if ($this->is_ascii($str) === FALSE) { - if (ICONV_ENABLED) + if (MB_ENABLED) { - $str = @iconv('UTF-8', 'UTF-8//IGNORE', $str); + $str = mb_convert_encoding($str, 'UTF-8', 'UTF-8'); } - elseif (MB_ENABLED) + elseif (ICONV_ENABLED) { - $str = mb_convert_encoding($str, 'UTF-8', 'UTF-8'); + $str = @iconv('UTF-8', 'UTF-8//IGNORE', $str); } } @@ -123,13 +123,13 @@ class CI_Utf8 { */ public function convert_to_utf8($str, $encoding) { - if (ICONV_ENABLED) + if (MB_ENABLED) { - return @iconv($encoding, 'UTF-8', $str); + return mb_convert_encoding($str, 'UTF-8', $encoding); } - elseif (MB_ENABLED === TRUE) + elseif (ICONV_ENABLED) { - return @mb_convert_encoding($str, 'UTF-8', $encoding); + return @iconv($encoding, 'UTF-8', $str); } return FALSE; -- cgit v1.2.3-24-g4f1b