From 172a285e2bfc39c728645b390779d551200ad8cb Mon Sep 17 00:00:00 2001 From: gggeek <giunta.gaetano@gmail.com> Date: Thu, 12 Jan 2023 17:51:45 +0000 Subject: [PATCH] allow polyfilling mbstring --- src/Encoder.php | 3 +-- src/Request.php | 3 +-- src/Server.php | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Encoder.php b/src/Encoder.php index 0d8ef53e..7691503a 100644 --- a/src/Encoder.php +++ b/src/Encoder.php @@ -326,8 +326,7 @@ class Encoder // The following code might be better for mb_string enabled installs, but makes the lib about 200% slower... //if (!is_valid_charset($valEncoding, array('UTF-8')) if (!in_array($valEncoding, array('UTF-8', 'US-ASCII')) && !XMLParser::hasEncoding($xmlVal)) { - /// @todo replace with function_exists - if (extension_loaded('mbstring')) { + if (function_exists('mb_convert_encoding')) { $xmlVal = mb_convert_encoding($xmlVal, 'UTF-8', $valEncoding); } else { if ($valEncoding == 'ISO-8859-1') { diff --git a/src/Request.php b/src/Request.php index f9b84bc2..2905a397 100644 --- a/src/Request.php +++ b/src/Request.php @@ -320,8 +320,7 @@ class Request // The following code might be better for mb_string enabled installs, but makes the lib about 200% slower... //if (!is_valid_charset($respEncoding, array('UTF-8'))) if (!in_array($respEncoding, array('UTF-8', 'US-ASCII')) && !XMLParser::hasEncoding($data)) { - /// @todo replace with function_exists - if (extension_loaded('mbstring')) { + if (function_exists('mb_convert_encoding')) { $data = mb_convert_encoding($data, 'UTF-8', $respEncoding); } else { if ($respEncoding == 'ISO-8859-1') { diff --git a/src/Server.php b/src/Server.php index f4afcd86..badb36eb 100644 --- a/src/Server.php +++ b/src/Server.php @@ -583,8 +583,7 @@ class Server // makes the lib about 200% slower... //if (!is_valid_charset($reqEncoding, array('UTF-8'))) if (!in_array($reqEncoding, array('UTF-8', 'US-ASCII')) && !XMLParser::hasEncoding($data)) { - /// @todo replace with function_exists - if (extension_loaded('mbstring')) { + if (function_exists('mb_convert_encoding')) { $data = mb_convert_encoding($data, 'UTF-8', $reqEncoding); } else { if ($reqEncoding == 'ISO-8859-1') { -- 2.47.0