From 81dcab5b6629aae9d0953354dad9e2f44d67b5c4 Mon Sep 17 00:00:00 2001 From: codemasher Date: Thu, 21 Jan 2021 22:55:42 +0100 Subject: [PATCH] :octocat: detect source encoding --- src/QRCode.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/QRCode.php b/src/QRCode.php index aa455af0a..91761221c 100755 --- a/src/QRCode.php +++ b/src/QRCode.php @@ -18,7 +18,7 @@ use chillerlan\QRCode\Data\{ use chillerlan\QRCode\Common\{ECICharset, MaskPattern, Mode}; use chillerlan\QRCode\Output\{QRCodeOutputException, QRFpdf, QRImage, QRImagick, QRMarkup, QROutputInterface, QRString}; use chillerlan\Settings\SettingsContainerInterface; -use function class_exists, in_array, mb_convert_encoding, mb_internal_encoding; +use function class_exists, in_array, mb_convert_encoding, mb_detect_encoding; /** * Turns a text string into a Model 2 QR Code @@ -279,7 +279,7 @@ class QRCode{ $eciCharsetName = $eciCharset->getName(); // convert the string to the given charset if($eciCharsetName !== null){ - $data = mb_convert_encoding($data, $eciCharsetName, mb_internal_encoding()); + $data = mb_convert_encoding($data, $eciCharsetName, mb_detect_encoding($data)); // add ECI designator $this->addSegment(new ECI($eciCharset->getID())); $this->addSegment(new Byte($data));