if (isset($htmlspecialcharsCharsets[$charset])) { return htmlspecialchars($string, \ENT_QUOTES | \ENT_SUBSTITUTE,
$charset);
} if (isset($htmlspecialcharsCharsets[strtoupper($charset)])) { // cache the lowercase variant for future iterations
$htmlspecialcharsCharsets[$charset] = true;
return htmlspecialchars($string, \ENT_QUOTES | \ENT_SUBSTITUTE,
$charset);
} $string =
twig_convert_encoding($string, 'UTF-8',
$charset);
$string =
htmlspecialchars($string, \ENT_QUOTES | \ENT_SUBSTITUTE, 'UTF-8'
);
return iconv('UTF-8',
$charset,
$string);
case 'js':
// escape all non-alphanumeric characters
// into their \x or \uHHHH representations
if ('UTF-8' !==
$charset) { $string =
twig_convert_encoding($string, 'UTF-8',
$charset);
}