59 trigger_error(
'TYPO3\'s JavaScriptEncoder will be removed in TYPO3 v10.0, use PHPs native json_encode() or GeneralUtility::quoteJSvalue() instead.', E_USER_DEPRECATED);
60 $this->charsetConversion = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\
TYPO3\CMS\Core\Charset\CharsetConverter::class);
61 for ($i = 0; $i < 256; $i++) {
62 if ($i >= ord(
'0') && $i <= ord(
'9') || $i >= ord(
'A') && $i <= ord(
'Z') || $i >= ord(
'a') && $i <= ord(
'z')) {
63 $this->hexMatrix[$i] =
null;
65 $this->hexMatrix[$i] = dechex($i);
78 $stringLength = mb_strlen($input,
'utf-8');
80 for ($i = 0; $i < $stringLength; $i++) {
81 $c = mb_substr($input, $i, 1,
'utf-8');
84 return $encodedString;
102 $ordinalValue = $this->charsetConversion->utf8CharToUnumber($character);
109 if ($ordinalValue < 256) {
110 $pad = substr(
'00', strlen($hex));
111 return '\\x' . $pad . strtoupper($hex);
114 $pad = substr(
'0000', strlen($hex));
115 return '\\u' . $pad . strtoupper($hex);
126 return in_array($character, $this->immuneCharacters,
true);
141 if ($ordinalValue <= 255) {
142 return $this->hexMatrix[$ordinalValue];
144 return dechex($ordinalValue);