From 8d25c83380a18330f479663f4a2aebaeb893a151 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 10 Nov 2021 12:43:03 +0100 Subject: [PATCH] fix/catch PHP 8.0 ValueError: mb_convert_encoding(): Argument #3 ($from_encoding) contains invalid encoding "cp1250" --- api/src/Translation.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/api/src/Translation.php b/api/src/Translation.php index 9fefc4f2d1..961177f7aa 100644 --- a/api/src/Translation.php +++ b/api/src/Translation.php @@ -947,9 +947,14 @@ class Translation { return utf8_decode($data); } - if (self::$mbstring && !$prefer_iconv && ($data = @mb_convert_encoding($data,$to,$from)) != '') - { - return $data; + try { + if (self::$mbstring && !$prefer_iconv && ($data = @mb_convert_encoding($data, $to, $from)) != '') + { + return $data; + } + } + catch (\ValueError $e) { + // ignore encodings unknown to mb_convert_encoding } if (function_exists('iconv')) {