public static function toUtf8($content, $charset)
    {
        $charset = strtoupper($charset);

        if (empty($charset) || $charset === 'UTF-8') {
            return $content;
        }

        $encodings = array_map('strtoupper', mb_list_encodings());

        if (in_array($charset, $encodings, true)) {
            return mb_convert_encoding($content, 'UTF-8', $charset);
        }

        if (function_exists('iconv')) {
            return iconv($charset, 'UTF-8//TRANSLIT//IGNORE', $content);
        }

        return $content;
    }
public static function toUtf8($content, $charset)
    {
        $charset = strtoupper($charset);

        if (empty($charset) || $charset === 'UTF-8') {
            return $content;
        }

        $encodings = array_map('strtoupper', mb_list_encodings());

        if (in_array($charset, $encodings, true)) {
            return mb_convert_encoding($content, 'UTF-8', $charset);
        }

        if (function_exists('iconv')) {
            return iconv($charset, 'UTF-8//TRANSLIT//IGNORE', $content);
        }

        return $content;
    }
public static function toUtf8 ( $ content , $ charset ) { $ charset = strtoupper ( $ charset ) ; if ( empty ( $ charset ) || $ charset === 'UTF-8' ) { return $ content ; } $ encodings = array_map ( 'strtoupper' , mb_list_encodings ( ) ) ; if ( in_array ( $ charset , $ encodings , true ) ) { return mb_convert_encoding ( $ content , 'UTF-8' , $ charset ) ; } if ( function_exists ( 'iconv' ) ) { return iconv ( $ charset , 'UTF-8//TRANSLIT//IGNORE' , $ content ) ; } return $ content ; }
Convert a string to utf-8.

@param string $content The content to convert
@param string $charset The original charset

@return string
Convert a string to utf - 8 .