本文整理汇总了PHP中QRspec::lengthIndicator方法的典型用法代码示例。如果您正苦于以下问题:PHP QRspec::lengthIndicator方法的具体用法?PHP QRspec::lengthIndicator怎么用?PHP QRspec::lengthIndicator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRspec
的用法示例。
在下文中一共展示了QRspec::lengthIndicator方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: eat8
public function eat8()
{
$la = QRspec::lengthIndicator(QR_MODE_AN, $this->input->getVersion());
$ln = QRspec::lengthIndicator(QR_MODE_NUM, $this->input->getVersion());
$p = 1;
$dataStrLen = strlen($this->dataStr);
while ($p < $dataStrLen) {
$mode = $this->identifyMode($p);
if ($mode == QR_MODE_KANJI) {
break;
}
if ($mode == QR_MODE_NUM) {
$q = $p;
while (self::isdigitat($this->dataStr, $q)) {
$q++;
}
$dif = QRinput::estimateBitsMode8($p) + QRinput::estimateBitsModeNum($q - $p) + 4 + $ln - QRinput::estimateBitsMode8($q);
// - 4 - l8
if ($dif < 0) {
break;
} else {
$p = $q;
}
} else {
if ($mode == QR_MODE_AN) {
$q = $p;
while (self::isalnumat($this->dataStr, $q)) {
$q++;
}
$dif = QRinput::estimateBitsMode8($p) + QRinput::estimateBitsModeAn($q - $p) + 4 + $la - QRinput::estimateBitsMode8($q);
// - 4 - l8
if ($dif < 0) {
break;
} else {
$p = $q;
}
} else {
$p++;
}
}
}
$run = $p;
$ret = $this->input->append(QR_MODE_8, $run, str_split($this->dataStr));
if ($ret < 0) {
return -1;
}
return $run;
}
示例2: lengthOfCode
public static function lengthOfCode($mode, $version, $bits)
{
$payload = $bits - 4 - QRspec::lengthIndicator($mode, $version);
switch ($mode) {
case Constants::QR_MODE_NUM:
$chunks = (int) ($payload / 10);
$remain = $payload - $chunks * 10;
$size = $chunks * 3;
if ($remain >= 7) {
$size += 2;
} else {
if ($remain >= 4) {
$size += 1;
}
}
break;
case Constants::QR_MODE_AN:
$chunks = (int) ($payload / 11);
$remain = $payload - $chunks * 11;
$size = $chunks * 2;
if ($remain >= 6) {
$size++;
}
break;
case Constants::QR_MODE_8:
$size = (int) ($payload / 8);
break;
case Constants::QR_MODE_KANJI:
$size = (int) ($payload / 13 * 2);
break;
case Constants::QR_MODE_STRUCTURE:
$size = (int) ($payload / 8);
break;
default:
$size = 0;
break;
}
$maxsize = QRspec::maximumWords($mode, $version);
if ($size < 0) {
$size = 0;
}
if ($size > $maxsize) {
$size = $maxsize;
}
return $size;
}
示例3: estimateBitStreamSizeOfEntry
public function estimateBitStreamSizeOfEntry($version)
{
$bits = 0;
if ($version == 0) {
$version = 1;
}
switch ($this->mode) {
case QR_MODE_NUM:
$bits = QRinput::estimateBitsModeNum($this->size);
break;
case QR_MODE_AN:
$bits = QRinput::estimateBitsModeAn($this->size);
break;
case QR_MODE_8:
$bits = QRinput::estimateBitsMode8($this->size);
break;
case QR_MODE_KANJI:
$bits = QRinput::estimateBitsModeKanji($this->size);
break;
case QR_MODE_STRUCTURE:
return STRUCTURE_HEADER_BITS;
default:
return 0;
}
$l = QRspec::lengthIndicator($this->mode, $version);
$m = 1 << $l;
$num = (int) (($this->size + $m - 1) / $m);
$bits += $num * (4 + $l);
return $bits;
}
示例4: eat8
public function eat8()
{
$la = QRspec::lengthIndicator(QR_MODE_AN, $this->input->getVersion());
$ln = QRspec::lengthIndicator(QR_MODE_NUM, $this->input->getVersion());
$p = 1;
//$dataStrLen = strlen($this->dataStr);
$dataStrLen = mb_strlen($this->dataStr, 'CP1251');
$_str = $this->dataStr;
$_p = 0;
while ($p < $dataStrLen) {
$mode = $this->identifyMode($p);
if ($mode == QR_MODE_KANJI) {
break;
}
if ($mode == QR_MODE_NUM) {
$q = $p;
while (self::isdigitat($this->dataStr, $q)) {
$q++;
}
$dif = QRinput::estimateBitsMode8($p) + QRinput::estimateBitsModeNum($q - $p) + 4 + $ln - QRinput::estimateBitsMode8($q);
// - 4 - l8
if ($dif < 0) {
break;
} else {
$p = $q;
}
} else {
if ($mode == QR_MODE_AN) {
$q = $p;
while (self::isalnumat($this->dataStr, $q)) {
$q++;
}
$dif = QRinput::estimateBitsMode8($p) + QRinput::estimateBitsModeAn($q - $p) + 6 + $la - QRinput::estimateBitsMode8($q);
// - 4 - l8
if ($dif < 0) {
break;
} else {
$p = $q;
}
} else {
if (BX_UTF === true) {
$value = ord($_str[$p]);
if ($value > 127) {
if ($value >= 192 && $value <= 223) {
$s = 1;
} elseif ($value >= 224 && $value <= 239) {
$s = 2;
} elseif ($value >= 240 && $value <= 247) {
$s = 3;
}
} else {
$s = 0;
}
$p = $p + $s;
$_p = $_p + $s;
}
$p++;
}
}
}
$run = $p;
$ret = $this->input->append(QR_MODE_8, $run, str_split($this->dataStr));
if ($ret < 0) {
return -1;
}
return $run - $_p;
}