private function isUtf8($string)
    {
        $encoding = mb_detect_encoding($string);
        if ($encoding == 'UTF-8') {
            return true;
        }
        
        $regex = array(
            '[\xC2-\xDF][\x80-\xBF]',
            '\xE0[\xA0-\xBF][\x80-\xBF]',
            '[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}',
            '\xED[\x80-\x9F][\x80-\xBF]',
            '\xF0[\x90-\xBF][\x80-\xBF]{2}',
            '[\xF1-\xF3][\x80-\xBF]{3}',
            '\xF4[\x80-\x8F][\x80-\xBF]{2}');
        
        $count = ceil(strlen($string) / 5000);
        for ($i = 0; $i < $count; $i++) {
            if (preg_match('%(?:'. implode('|', $regex).')+%xs', substr($string, ($i * 5000), 5000))) {
                return false;
            }
        }
        
        return true;
    }
private function isUtf8($string)
    {
        $encoding = mb_detect_encoding($string);
        if ($encoding == 'UTF-8') {
            return true;
        }
        
        $regex = array(
            '[\xC2-\xDF][\x80-\xBF]',
            '\xE0[\xA0-\xBF][\x80-\xBF]',
            '[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}',
            '\xED[\x80-\x9F][\x80-\xBF]',
            '\xF0[\x90-\xBF][\x80-\xBF]{2}',
            '[\xF1-\xF3][\x80-\xBF]{3}',
            '\xF4[\x80-\x8F][\x80-\xBF]{2}');
        
        $count = ceil(strlen($string) / 5000);
        for ($i = 0; $i < $count; $i++) {
            if (preg_match('%(?:'. implode('|', $regex).')+%xs', substr($string, ($i * 5000), 5000))) {
                return false;
            }
        }
        
        return true;
    }
private function isUtf8 ( $ string ) { $ encoding = mb_detect_encoding ( $ string ) ; if ( $ encoding == 'UTF-8' ) { return true ; } $ regex = array ( '[\xC2-\xDF][\x80-\xBF]' , '\xE0[\xA0-\xBF][\x80-\xBF]' , '[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}' , '\xED[\x80-\x9F][\x80-\xBF]' , '\xF0[\x90-\xBF][\x80-\xBF]{2}' , '[\xF1-\xF3][\x80-\xBF]{3}' , '\xF4[\x80-\x8F][\x80-\xBF]{2}' ) ; $ count = ceil ( strlen ( $ string ) / 5000 ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { if ( preg_match ( '%(?:' . implode ( '|' , $ regex ) . ')+%xs' , substr ( $ string , ( $ i * 5000 ) , 5000 ) ) ) { return false ; } } return true ; }
Returns true if there's UTF encodeing

@param *string The string to test

@return bool
Returns true if there s UTF encodeing