src/mako/view/renderers/traits/EscaperTrait.php
public function escapeJavascript(?string $string, string $charset): string
	{
		if($charset !== 'UTF-8')
		{
			$string = mb_convert_encoding($string, 'UTF-8', $charset);
		}

		$string = preg_replace_callback('/[^a-z0-9,\._]/iSu', [$this, 'javascriptEscaper'], $string);

		if($charset !== 'UTF-8')
		{
			$string = mb_convert_encoding($string, $charset, 'UTF-8');
		}

		return $string;
	}
public function escapeJavascript(?string $string, string $charset): string
	{
		if($charset !== 'UTF-8')
		{
			$string = mb_convert_encoding($string, 'UTF-8', $charset);
		}

		$string = preg_replace_callback('/[^a-z0-9,\._]/iSu', [$this, 'javascriptEscaper'], $string);

		if($charset !== 'UTF-8')
		{
			$string = mb_convert_encoding($string, $charset, 'UTF-8');
		}

		return $string;
	}
public function escapeJavascript ( ? string $ string , string $ charset ) : string { if ( $ charset !== 'UTF-8' ) { $ string = mb_convert_encoding ( $ string , 'UTF-8' , $ charset ) ; } $ string = preg_replace_callback ( '/[^a-z0-9,\._]/iSu' , [ $ this , 'javascriptEscaper' ] , $ string ) ; if ( $ charset !== 'UTF-8' ) { $ string = mb_convert_encoding ( $ string , $ charset , 'UTF-8' ) ; } return $ string ; }
Returns a string that has been escaped for a Javascript context.

@param  string|null $string  String to escape
@param  string      $charset Character set
@return string
Returns a string that has been escaped for a Javascript context .