mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-24 19:57:51 +00:00
:octocat: ECI::parseValue(): return ECICharset object
This commit is contained in:
+5
-9
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace chillerlan\QRCode\Data;
|
||||
|
||||
use chillerlan\QRCode\Common\{BitBuffer, Mode};
|
||||
use chillerlan\QRCode\Common\{BitBuffer, ECICharset, Mode};
|
||||
|
||||
/**
|
||||
* Adds an ECI Designator
|
||||
@@ -54,26 +54,22 @@ final class ECI extends QRDataModeAbstract{
|
||||
/**
|
||||
* @throws \chillerlan\QRCode\Data\QRCodeDataException
|
||||
*/
|
||||
public static function parseValue(BitBuffer $bitBuffer):int{
|
||||
public static function parseValue(BitBuffer $bitBuffer):ECICharset{
|
||||
$firstByte = $bitBuffer->read(8);
|
||||
|
||||
if(($firstByte & 0x80) === 0){
|
||||
// just one byte
|
||||
return $firstByte & 0x7f;
|
||||
return new ECICharset($firstByte & 0x7f);
|
||||
}
|
||||
|
||||
if(($firstByte & 0xc0) === 0x80){
|
||||
// two bytes
|
||||
$secondByte = $bitBuffer->read(8);
|
||||
|
||||
return (($firstByte & 0x3f) << 8) | $secondByte;
|
||||
return new ECICharset((($firstByte & 0x3f) << 8) | $bitBuffer->read(8));
|
||||
}
|
||||
|
||||
if(($firstByte & 0xe0) === 0xC0){
|
||||
// three bytes
|
||||
$secondThirdBytes = $bitBuffer->read(16);
|
||||
|
||||
return (($firstByte & 0x1f) << 16) | $secondThirdBytes;
|
||||
return new ECICharset((($firstByte & 0x1f) << 16) | $bitBuffer->read(16));
|
||||
}
|
||||
|
||||
throw new QRCodeDataException('error decoding ECI value');
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace chillerlan\QRCode\Decoder;
|
||||
|
||||
use Exception, InvalidArgumentException, RuntimeException;
|
||||
use chillerlan\QRCode\Common\{BitBuffer, EccLevel, ECICharset, Mode, ReedSolomonDecoder, Version};
|
||||
use chillerlan\QRCode\Common\{BitBuffer, EccLevel, Mode, ReedSolomonDecoder, Version};
|
||||
use chillerlan\QRCode\Data\{AlphaNum, Byte, ECI, Kanji, Number};
|
||||
use chillerlan\QRCode\Detector\Detector;
|
||||
use function count, array_fill, mb_convert_encoding, mb_detect_encoding;
|
||||
@@ -246,8 +246,7 @@ final class Decoder{
|
||||
|
||||
if($datamode === Mode::DATA_ECI){
|
||||
// Count doesn't apply to ECI
|
||||
$value = ECI::parseValue($bits);
|
||||
$eciCharset = new ECICharset($value);
|
||||
$eciCharset = ECI::parseValue($bits);
|
||||
}
|
||||
/** @noinspection PhpStatementHasEmptyBodyInspection */
|
||||
elseif($datamode === Mode::DATA_FNC1_FIRST || $datamode === Mode::DATA_FNC1_SECOND){
|
||||
|
||||
Reference in New Issue
Block a user