Skip to content

Commit e4ca6f4

Browse files
committed
uses mb_string when iconv is not available
1 parent f6d8ff8 commit e4ca6f4

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

composer.json

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
],
1717
"require": {
1818
"php": ">=7.1",
19-
"ext-iconv": "*",
2019
"ext-json": "*"
2120
},
2221
"require-dev": {

src/Neon/Decoder.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,14 @@ private function cbString(array $m): string
367367
if ($code >= 0xD800 && $code <= 0xDFFF) {
368368
$this->error("Invalid UTF-8 (lone surrogate) $sq");
369369
}
370-
return iconv('UTF-32BE', 'UTF-8//IGNORE', pack('N', $code));
370+
return function_exists('iconv')
371+
? iconv('UTF-32BE', 'UTF-8//IGNORE', pack('N', $code))
372+
: mb_convert_encoding(pack('N', $code), 'UTF-8', 'UTF-32BE');
373+
371374
} elseif ($sq[1] === 'x' && strlen($sq) === 4) {
372375
trigger_error("Neon: '$sq' is deprecated, use '\\uXXXX' instead.", E_USER_DEPRECATED);
373376
return chr(hexdec(substr($sq, 2)));
377+
374378
} else {
375379
$this->error("Invalid escaping sequence $sq");
376380
}

0 commit comments

Comments
 (0)