protected function convertCharset($string, $charsets)
    {
        if (function_exists('iconv')
            && !empty($charsets)
        ) {
            $charset = $charsets[0];
            if (count($charsets) > 1
                && function_exists('mb_detect_encoding')
            ) {
                $charset = mb_detect_encoding($string, $charsets);
                if ($charset === false) {
                    $charset = $charsets[0];
                }
            }

            $newKey = @iconv($charset, 'UTF-8//IGNORE', $string);
            if (!empty($newKey)) {
                $string = $newKey;
            }
        }

        return $string;
    }
protected function convertCharset($string, $charsets)
    {
        if (function_exists('iconv')
            && !empty($charsets)
        ) {
            $charset = $charsets[0];
            if (count($charsets) > 1
                && function_exists('mb_detect_encoding')
            ) {
                $charset = mb_detect_encoding($string, $charsets);
                if ($charset === false) {
                    $charset = $charsets[0];
                }
            }

            $newKey = @iconv($charset, 'UTF-8//IGNORE', $string);
            if (!empty($newKey)) {
                $string = $newKey;
            }
        }

        return $string;
    }
protected function convertCharset ( $ string , $ charsets ) { if ( function_exists ( 'iconv' ) && ! empty ( $ charsets ) ) { $ charset = $ charsets [ 0 ] ; if ( count ( $ charsets ) > 1 && function_exists ( 'mb_detect_encoding' ) ) { $ charset = mb_detect_encoding ( $ string , $ charsets ) ; if ( $ charset === false ) { $ charset = $ charsets [ 0 ] ; } } $ newKey = @ iconv ( $ charset , 'UTF-8//IGNORE' , $ string ) ; if ( ! empty ( $ newKey ) ) { $ string = $ newKey ; } } return $ string ; }
Tries to convert the given string from one of the given charsets to UTF-8
@param string $string
@param array $charsets
@return string
Tries to convert the given string from one of the given charsets to UTF - 8