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))); }