From 7b56403d10d56ccfc95d04bebd68492162692a1a Mon Sep 17 00:00:00 2001 From: uzulla Date: Mon, 6 Oct 2025 09:04:20 +0900 Subject: [PATCH] fix: wrong mb_encoding_aliases() handling for PHP 8.0+ --- src/Document.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Document.php b/src/Document.php index 5ee56c5c..ddb8364c 100644 --- a/src/Document.php +++ b/src/Document.php @@ -74,9 +74,9 @@ private function getValidEncoding(?string $encoding): ?string } else { // PHP 8.0+: ValueError exception is thrown for invalid/empty encoding try { - $aliases = mb_encoding_aliases($encoding ?? ''); - // Check if aliases array is not empty (valid encoding should have at least one alias) - return !empty($aliases) ? $encoding : null; + mb_encoding_aliases($encoding ?? ''); + // If mb_encoding_aliases succeeds, return the input value as is. Some encodings do not have aliases. + return $encoding; } catch (\ValueError $exception) { return null; }