protected function convertEncoding($string, $to, $from)
    {
        $result = '';
        if (function_exists('iconv')) {
            $result = iconv($from, $to, $string);
        } elseif (function_exists('mb_convert_encoding')) {
            $result = mb_convert_encoding($string, $to, $from);
        } else {
            throw new \RuntimeException(
                get_class($this)
                . ' requires either the iconv or mbstring extension to be installed'
                . ' when escaping for non UTF-8 strings.'
            );
        }

        if ($result === false) {
            return ''; // return non-fatal blank string on encoding errors from users
        }
        return $result;
    }
protected function convertEncoding($string, $to, $from)
    {
        $result = '';
        if (function_exists('iconv')) {
            $result = iconv($from, $to, $string);
        } elseif (function_exists('mb_convert_encoding')) {
            $result = mb_convert_encoding($string, $to, $from);
        } else {
            throw new \RuntimeException(
                get_class($this)
                . ' requires either the iconv or mbstring extension to be installed'
                . ' when escaping for non UTF-8 strings.'
            );
        }

        if ($result === false) {
            return ''; // return non-fatal blank string on encoding errors from users
        }
        return $result;
    }
protected function convertEncoding ( $ string , $ to , $ from ) { $ result = '' ; if ( function_exists ( 'iconv' ) ) { $ result = iconv ( $ from , $ to , $ string ) ; } elseif ( function_exists ( 'mb_convert_encoding' ) ) { $ result = mb_convert_encoding ( $ string , $ to , $ from ) ; } else { throw new \ RuntimeException ( get_class ( $ this ) . ' requires either the iconv or mbstring extension to be installed' . ' when escaping for non UTF-8 strings.' ) ; } if ( $ result === false ) { return '' ; // return non-fatal blank string on encoding errors from users } return $ result ; }
Encoding conversion helper which wraps iconv and mbstring where they exist or throws
and exception where neither is available.

@param string $string
@param string $to
@param array|string $from
@throws \RuntimeException
@return string
Encoding conversion helper which wraps iconv and mbstring where they exist or throws and exception where neither is available .