Escape::escapeJSChar PHP Method

escapeJSChar() protected static method

Callback function for preg_replace_callback() that applies Javascript escaping to all matches.
protected static escapeJSChar ( array $matches ) : string
$matches array
return string
    protected static function escapeJSChar($matches)
    {
        $char = $matches[0];
        if (str::length($char) == 1) {
            return sprintf('\\x%02X', ord($char));
        }
        $char = static::convertEncoding($char);
        return sprintf('\\u%04s', str::upper(bin2hex($char)));
    }