Skip to content

Commit

Permalink
Merge pull request #1418 from stripe/anniel-deprecated-utf8_encode
Browse files Browse the repository at this point in the history
Switch to mb_convert_encoding to fix utf8_encode deprecation warning
  • Loading branch information
anniel-stripe authored Jan 4, 2023
2 parents 417d66a + 66eede1 commit c7c4acc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Util/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -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. ' .
Expand All @@ -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', 'ISO-8859-1');
}

return $value;
Expand Down

0 comments on commit c7c4acc

Please sign in to comment.