Welcome Guest, Not a member yet? Register   Sign In
UTF8 and string functions
#1

[eluser]Sillysoft[/eluser]
Using CI I want to create a site that supports multiple languages. So using utf8 for the site. I understand what needs to be done for utf8 connecting and getting data from the db, my question is how does CI handle things like string functions when you run rules against form data? So lets say I have a form and one of the fields I need to make sure its not empty and the minimum length is 8 characters. If I use the rules in CI for that wouldnt it break? Or does CI automatically check to see if the mb function is available for string functions before using the default string function? And Im not just referring to strlen, Im also referring to other functions like substr, htmlentities, regex etc that require additional steps to make it work for utf8 encoded data. Does CI have a way to automatically use utf8 specific php functions?
#2

[eluser]n0xie[/eluser]
You can look at the source code to figure out what's going on. It's not rocket surgery after all ;-)

Code:
function max_length($str, $val)
    {
        if (preg_match("/[^0-9]/", $val))
        {
            return FALSE;
        }

        if (function_exists('mb_strlen'))
        {
            return (mb_strlen($str) > $val) ? FALSE : TRUE;
        }

        return (strlen($str) > $val) ? FALSE : TRUE;
    }




Theme © iAndrew 2016 - Forum software by © MyBB