From 624d3215be379f0646a6be8a09f0f527793133fe Mon Sep 17 00:00:00 2001 From: Annie Li Date: Tue, 3 Jan 2023 11:16:44 -0800 Subject: [PATCH 1/3] Switch to mb_convert_encoding to fix utf8_encode deprecation warning --- lib/Util/Util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Util/Util.php b/lib/Util/Util.php index 4f390500a..4cf77eb61 100644 --- a/lib/Util/Util.php +++ b/lib/Util/Util.php @@ -85,7 +85,7 @@ public static function utf8($value) } if (\is_string($value) && self::$isMbstringAvailable && 'UTF-8' !== \mb_detect_encoding($value, 'UTF-8', true)) { - return \utf8_encode($value); + return mb_convert_encoding($value, 'UTF-8', mb_list_encodings()); } return $value; From 1b01c6574ed339617b04b748aeb959ea2cc265eb Mon Sep 17 00:00:00 2001 From: Annie Li Date: Tue, 3 Jan 2023 12:38:25 -0800 Subject: [PATCH 2/3] Go back to converting from Latin-1 --- lib/Util/Util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Util/Util.php b/lib/Util/Util.php index 4cf77eb61..b1d6643cc 100644 --- a/lib/Util/Util.php +++ b/lib/Util/Util.php @@ -85,7 +85,7 @@ public static function utf8($value) } if (\is_string($value) && self::$isMbstringAvailable && 'UTF-8' !== \mb_detect_encoding($value, 'UTF-8', true)) { - return mb_convert_encoding($value, 'UTF-8', mb_list_encodings()); + return mb_convert_encoding($value, 'UTF-8', 'ISO-8859-1'); } return $value; From 66eede1d26b26c97f5dfa123d8c4f33f5e37934d Mon Sep 17 00:00:00 2001 From: Annie Li Date: Tue, 3 Jan 2023 13:22:27 -0800 Subject: [PATCH 3/3] Make sure mb_convert_encoding also exists --- lib/Util/Util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Util/Util.php b/lib/Util/Util.php index b1d6643cc..9ebc413ca 100644 --- a/lib/Util/Util.php +++ b/lib/Util/Util.php @@ -74,7 +74,7 @@ public static function convertToStripeObject($resp, $opts) public static function utf8($value) { if (null === self::$isMbstringAvailable) { - self::$isMbstringAvailable = \function_exists('mb_detect_encoding'); + self::$isMbstringAvailable = \function_exists('mb_detect_encoding') && \function_exists('mb_convert_encoding'); if (!self::$isMbstringAvailable) { \trigger_error('It looks like the mbstring extension is not enabled. ' .