Symfony\Component\Templating\PhpEngine::convertEncoding PHP Method

convertEncoding() public method

Convert a string from one encoding to another.
public convertEncoding ( string $string, string $to, string $from ) : string
$string string The string to convert
$to string The input encoding
$from string The output encoding
return string The string with the new encoding
    public function convertEncoding($string, $to, $from)
    {
        if (function_exists('iconv')) {
            return iconv($from, $to, $string);
        } elseif (function_exists('mb_convert_encoding')) {
            return mb_convert_encoding($string, $to, $from);
        }

        throw new \RuntimeException('No suitable convert encoding function (use UTF-8 as your encoding or install the iconv or mbstring extension).');
    }