| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Class ECICharset |
| 5 |
* |
| 6 |
* @created 21.01.2021 |
| 7 |
* @author ZXing Authors |
| 8 |
* @author smiley <[email protected]> |
| 9 |
* @copyright 2021 smiley |
| 10 |
* @license Apache-2.0 |
| 11 |
*/ |
| 12 |
namespace WCPOS\Vendor\chillerlan\QRCode\Common; |
| 13 |
|
| 14 |
use WCPOS\Vendor\chillerlan\QRCode\QRCodeException; |
| 15 |
use function sprintf; |
| 16 |
/** |
| 17 |
* ISO/IEC 18004:2000 - 8.4.1 Extended Channel Interpretation (ECI) Mode |
| 18 |
*/ |
| 19 |
final class ECICharset |
| 20 |
{ |
| 21 |
public const CP437 = 0; |
| 22 |
// Code page 437, DOS Latin US |
| 23 |
public const ISO_IEC_8859_1_GLI = 1; |
| 24 |
// GLI encoding with characters 0 to 127 identical to ISO/IEC 646 and characters 128 to 255 identical to ISO 8859-1 |
| 25 |
public const CP437_WO_GLI = 2; |
| 26 |
// An equivalent code table to CP437, without the return-to-GLI 0 logic |
| 27 |
public const ISO_IEC_8859_1 = 3; |
| 28 |
// Latin-1 (Default) |
| 29 |
public const ISO_IEC_8859_2 = 4; |
| 30 |
// Latin-2 |
| 31 |
public const ISO_IEC_8859_3 = 5; |
| 32 |
// Latin-3 |
| 33 |
public const ISO_IEC_8859_4 = 6; |
| 34 |
// Latin-4 |
| 35 |
public const ISO_IEC_8859_5 = 7; |
| 36 |
// Latin/Cyrillic |
| 37 |
public const ISO_IEC_8859_6 = 8; |
| 38 |
// Latin/Arabic |
| 39 |
public const ISO_IEC_8859_7 = 9; |
| 40 |
// Latin/Greek |
| 41 |
public const ISO_IEC_8859_8 = 10; |
| 42 |
// Latin/Hebrew |
| 43 |
public const ISO_IEC_8859_9 = 11; |
| 44 |
// Latin-5 |
| 45 |
public const ISO_IEC_8859_10 = 12; |
| 46 |
// Latin-6 |
| 47 |
public const ISO_IEC_8859_11 = 13; |
| 48 |
// Latin/Thai |
| 49 |
// 14 reserved |
| 50 |
public const ISO_IEC_8859_13 = 15; |
| 51 |
// Latin-7 (Baltic Rim) |
| 52 |
public const ISO_IEC_8859_14 = 16; |
| 53 |
// Latin-8 (Celtic) |
| 54 |
public const ISO_IEC_8859_15 = 17; |
| 55 |
// Latin-9 |
| 56 |
public const ISO_IEC_8859_16 = 18; |
| 57 |
// Latin-10 |
| 58 |
// 19 reserved |
| 59 |
public const SHIFT_JIS = 20; |
| 60 |
// JIS X 0208 Annex 1 + JIS X 0201 |
| 61 |
public const WINDOWS_1250_LATIN_2 = 21; |
| 62 |
// Superset of Latin-2, Central Europe |
| 63 |
public const WINDOWS_1251_CYRILLIC = 22; |
| 64 |
// Latin/Cyrillic |
| 65 |
public const WINDOWS_1252_LATIN_1 = 23; |
| 66 |
// Superset of Latin-1 |
| 67 |
public const WINDOWS_1256_ARABIC = 24; |
| 68 |
public const ISO_IEC_10646_UCS_2 = 25; |
| 69 |
// High order byte first (UTF-16BE) |
| 70 |
public const ISO_IEC_10646_UTF_8 = 26; |
| 71 |
// UTF-8 |
| 72 |
public const ISO_IEC_646_1991 = 27; |
| 73 |
// International Reference Version of ISO 7-bit coded character set (US-ASCII) |
| 74 |
public const BIG5 = 28; |
| 75 |
// Big 5 (Taiwan) Chinese Character Set |
| 76 |
public const GB18030 = 29; |
| 77 |
// GB (PRC) Chinese Character Set |
| 78 |
public const EUC_KR = 30; |
| 79 |
// Korean Character Set |
| 80 |
/** |
| 81 |
* map of charset id -> name |
| 82 |
* |
| 83 |
* @see \mb_list_encodings() |
| 84 |
*/ |
| 85 |
public const MB_ENCODINGS = [ |
| 86 |
self::CP437 => null, |
| 87 |
self::ISO_IEC_8859_1_GLI => null, |
| 88 |
self::CP437_WO_GLI => null, |
| 89 |
self::ISO_IEC_8859_1 => 'ISO-8859-1', |
| 90 |
self::ISO_IEC_8859_2 => 'ISO-8859-2', |
| 91 |
self::ISO_IEC_8859_3 => 'ISO-8859-3', |
| 92 |
self::ISO_IEC_8859_4 => 'ISO-8859-4', |
| 93 |
self::ISO_IEC_8859_5 => 'ISO-8859-5', |
| 94 |
self::ISO_IEC_8859_6 => 'ISO-8859-6', |
| 95 |
self::ISO_IEC_8859_7 => 'ISO-8859-7', |
| 96 |
self::ISO_IEC_8859_8 => 'ISO-8859-8', |
| 97 |
self::ISO_IEC_8859_9 => 'ISO-8859-9', |
| 98 |
self::ISO_IEC_8859_10 => 'ISO-8859-10', |
| 99 |
self::ISO_IEC_8859_11 => null, |
| 100 |
self::ISO_IEC_8859_13 => 'ISO-8859-13', |
| 101 |
self::ISO_IEC_8859_14 => 'ISO-8859-14', |
| 102 |
self::ISO_IEC_8859_15 => 'ISO-8859-15', |
| 103 |
self::ISO_IEC_8859_16 => 'ISO-8859-16', |
| 104 |
self::SHIFT_JIS => 'SJIS', |
| 105 |
self::WINDOWS_1250_LATIN_2 => null, |
| 106 |
// @see https://www.php.net/manual/en/function.mb-convert-encoding.php#112547 |
| 107 |
self::WINDOWS_1251_CYRILLIC => 'Windows-1251', |
| 108 |
self::WINDOWS_1252_LATIN_1 => 'Windows-1252', |
| 109 |
self::WINDOWS_1256_ARABIC => null, |
| 110 |
// @see https://stackoverflow.com/a/8592995 |
| 111 |
self::ISO_IEC_10646_UCS_2 => 'UTF-16BE', |
| 112 |
self::ISO_IEC_10646_UTF_8 => 'UTF-8', |
| 113 |
self::ISO_IEC_646_1991 => 'ASCII', |
| 114 |
self::BIG5 => 'BIG-5', |
| 115 |
self::GB18030 => 'GB18030', |
| 116 |
self::EUC_KR => 'EUC-KR', |
| 117 |
]; |
| 118 |
/** |
| 119 |
* The current ECI character set ID |
| 120 |
*/ |
| 121 |
private int $charsetID; |
| 122 |
/** |
| 123 |
* @throws \chillerlan\QRCode\QRCodeException |
| 124 |
*/ |
| 125 |
public function __construct(int $charsetID) |
| 126 |
{ |
| 127 |
if ($charsetID < 0 || $charsetID > 999999) { |
| 128 |
throw new QRCodeException(sprintf('invalid charset id: "%s"', $charsetID)); |
| 129 |
} |
| 130 |
$this->charsetID = $charsetID; |
| 131 |
} |
| 132 |
/** |
| 133 |
* Returns the current character set ID |
| 134 |
*/ |
| 135 |
public function getID() : int |
| 136 |
{ |
| 137 |
return $this->charsetID; |
| 138 |
} |
| 139 |
/** |
| 140 |
* Returns the name of the current character set or null if no name is available |
| 141 |
* |
| 142 |
* @see \mb_convert_encoding() |
| 143 |
* @see \iconv() |
| 144 |
*/ |
| 145 |
public function getName() : ?string |
| 146 |
{ |
| 147 |
return self::MB_ENCODINGS[$this->charsetID] ?? null; |
| 148 |
} |
| 149 |
} |
| 150 |
|