mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-09-04 14:37:36 +00:00
:octocat: Kanji, Hanzi: do not mess with mb_detect_order(), feed the expected encodings directly into mb_detect_encoding()
(cherry picked from commit 3a610d2838)
This commit is contained in:
+6
-3
@@ -13,7 +13,7 @@ namespace chillerlan\QRCode\Data;
|
||||
use chillerlan\QRCode\Common\{BitBuffer, Mode};
|
||||
use Throwable;
|
||||
use function chr, implode, intdiv, is_string, mb_convert_encoding, mb_detect_encoding,
|
||||
mb_detect_order, mb_internal_encoding, mb_strlen, ord, sprintf, strlen;
|
||||
mb_internal_encoding, mb_strlen, ord, sprintf, strlen;
|
||||
|
||||
/**
|
||||
* Hanzi (simplified Chinese) mode, GBT18284-2000: 13-bit double-byte characters from the GB2312/GB18030 character set
|
||||
@@ -67,9 +67,12 @@ final class Hanzi extends QRDataModeAbstract{
|
||||
* @throws \chillerlan\QRCode\Data\QRCodeDataException
|
||||
*/
|
||||
public static function convertEncoding(string $string):string{
|
||||
mb_detect_order([mb_internal_encoding(), 'UTF-8', 'GB2312', 'GB18030', 'CP936', 'EUC-CN', 'HZ']);
|
||||
|
||||
$detected = mb_detect_encoding($string, null, true);
|
||||
$detected = mb_detect_encoding(
|
||||
$string,
|
||||
[mb_internal_encoding(), 'UTF-8', 'GB2312', 'GB18030', 'CP936', 'EUC-CN', 'HZ'],
|
||||
true,
|
||||
);
|
||||
|
||||
if($detected === false){
|
||||
throw new QRCodeDataException('mb_detect_encoding error');
|
||||
|
||||
+2
-4
@@ -13,7 +13,7 @@ namespace chillerlan\QRCode\Data;
|
||||
use chillerlan\QRCode\Common\{BitBuffer, Mode};
|
||||
use Throwable;
|
||||
use function chr, implode, intdiv, is_string, mb_convert_encoding, mb_detect_encoding,
|
||||
mb_detect_order, mb_internal_encoding, mb_strlen, ord, sprintf, strlen;
|
||||
mb_internal_encoding, mb_strlen, ord, sprintf, strlen;
|
||||
|
||||
/**
|
||||
* Kanji mode: 13-bit double-byte characters from the Shift-JIS character set
|
||||
@@ -60,9 +60,7 @@ final class Kanji extends QRDataModeAbstract{
|
||||
* @throws \chillerlan\QRCode\Data\QRCodeDataException
|
||||
*/
|
||||
public static function convertEncoding(string $string):string{
|
||||
mb_detect_order([mb_internal_encoding(), 'UTF-8', 'SJIS', 'SJIS-2004']);
|
||||
|
||||
$detected = mb_detect_encoding($string, null, true);
|
||||
$detected = mb_detect_encoding($string, [mb_internal_encoding(), 'UTF-8', 'SJIS', 'SJIS-2004'], true);
|
||||
|
||||
if($detected === false){
|
||||
throw new QRCodeDataException('mb_detect_encoding error');
|
||||
|
||||
Reference in New Issue
Block a user