src/mako/view/renderers/traits/EscaperTrait.php
protected function javascriptEscaper(array $matches): string
	{
		$chr = $matches[0];

		if(strlen($chr) === 1)
		{
			return sprintf('\\x%02X', ord($chr));
		}

		$chr = mb_convert_encoding($chr, 'UTF-16BE', 'UTF-8');

		return sprintf('\\u%04s', strtoupper(bin2hex($chr)));
	}
protected function javascriptEscaper(array $matches): string
	{
		$chr = $matches[0];

		if(strlen($chr) === 1)
		{
			return sprintf('\\x%02X', ord($chr));
		}

		$chr = mb_convert_encoding($chr, 'UTF-16BE', 'UTF-8');

		return sprintf('\\u%04s', strtoupper(bin2hex($chr)));
	}
protected function javascriptEscaper ( array $ matches ) : string { $ chr = $ matches [ 0 ] ; if ( strlen ( $ chr ) === 1 ) { return sprintf ( '\\x%02X' , ord ( $ chr ) ) ; } $ chr = mb_convert_encoding ( $ chr , 'UTF-16BE' , 'UTF-8' ) ; return sprintf ( '\\u%04s' , strtoupper ( bin2hex ( $ chr ) ) ) ; }
Escapes characters for use in a Javascript context.

(This method contains code from the SecurityMultiTool library).

@param  array  $matches Regex matches
@return string
Escapes characters for use in a Javascript context .