Codeigniter utf-8 character input data save issue

Codeigniter utf-8 character input data save issue

Codeigniter have utf-8 character input data save issue in some hosting servers like Etisalat.

system/core/Utf8.php have function to detect illegal char in input data(post/get). In some cases utf-8 char is consider as illegal and save function will fail.
For avoid data saving issue do the following in clean_string() function of Utf8.php at line 85.

$str = !mb_detect_encoding($str, 'UTF-8', TRUE) ? utf8_encode($str) : $str;
$str = @iconv('UTF-8', 'UTF-8//IGNORE', $str);
_is_ascii($str) === FALSE)
{
$str = !mb_detect_encoding($str, 'UTF-8', TRUE) ? utf8_encode($str) : $str;
$str = @iconv('UTF-8', 'UTF-8//IGNORE', $str);
}

return $str;
}

// --------------------------------------------------------------------


smarttips

Leave a Reply

Advertisment ad adsense adlogger