CI_Utf8-related changes
- Give priority to mb_convert_encoding() over iconv() in clean_string() (partially fixes #261)
- Add more proper unit tests
diff --git a/system/core/Utf8.php b/system/core/Utf8.php
index c789a7b..9a92efe 100644
--- a/system/core/Utf8.php
+++ b/system/core/Utf8.php
@@ -80,14 +80,14 @@
{
if ($this->is_ascii($str) === FALSE)
{
- if (ICONV_ENABLED)
- {
- $str = @iconv('UTF-8', 'UTF-8//IGNORE', $str);
- }
- elseif (MB_ENABLED)
+ if (MB_ENABLED)
{
$str = mb_convert_encoding($str, 'UTF-8', 'UTF-8');
}
+ elseif (ICONV_ENABLED)
+ {
+ $str = @iconv('UTF-8', 'UTF-8//IGNORE', $str);
+ }
}
return $str;
@@ -123,14 +123,14 @@
*/
public function convert_to_utf8($str, $encoding)
{
- if (ICONV_ENABLED)
+ if (MB_ENABLED)
+ {
+ return mb_convert_encoding($str, 'UTF-8', $encoding);
+ }
+ elseif (ICONV_ENABLED)
{
return @iconv($encoding, 'UTF-8', $str);
}
- elseif (MB_ENABLED === TRUE)
- {
- return @mb_convert_encoding($str, 'UTF-8', $encoding);
- }
return FALSE;
}