From: raortegar Date: Tue, 31 Jan 2023 13:37:34 +0000 (+0100) Subject: Fixed PHP 8.2 utf8_encode deprecated in Charset.php X-Git-Tag: 4.10.0~55^2 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=f0bdd46b6d680985cd448b89aad6836af6150f84;p=plcapi.git Fixed PHP 8.2 utf8_encode deprecated in Charset.php --- diff --git a/src/Helper/Charset.php b/src/Helper/Charset.php index d683140e..447eaa0b 100644 --- a/src/Helper/Charset.php +++ b/src/Helper/Charset.php @@ -253,7 +253,11 @@ class Charset case 'ISO-8859-1_UTF-8': $escapedData = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data); /// @todo if on php >= 8.2, prefer using mbstring or iconv. Also: suppress the warning! - $escapedData = utf8_encode($escapedData); + if (function_exists('mb_convert_encoding')) { + $escapedData = mb_convert_encoding($escapedData, 'UTF-8', 'ISO-8859-1'); + } else { + $escapedData = utf8_encode($escapedData); + } break; case 'ISO-8859-1_US-ASCII':