allow polyfilling mbstring
authorgggeek <giunta.gaetano@gmail.com>
Thu, 12 Jan 2023 17:51:45 +0000 (17:51 +0000)
committergggeek <giunta.gaetano@gmail.com>
Thu, 12 Jan 2023 17:51:45 +0000 (17:51 +0000)
src/Encoder.php
src/Request.php
src/Server.php

index 0d8ef53..7691503 100644 (file)
@@ -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') {
index f9b84bc..2905a39 100644 (file)
@@ -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') {
index f4afcd8..badb36e 100644 (file)
@@ -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') {