Home  >  Article  >  Backend Development  >  这JB代码终究想干嘛

这JB代码终究想干嘛

WBOY
WBOYOriginal
2016-06-13 11:55:23765browse

这JB代码到底想干嘛?

<br />$ln = $this->lengthIndicator($this->QR_MODE_NM, $this->version);<br />$dif = $this->estimateBitsModeNum($run) + 4 + $ln<br />			+ $this->estimateBitsMode8(1)         // + 4 + l8<br />			- $this->estimateBitsMode8($run + 1); // - 4 - l8<br />			if ($dif > 0) {<br />				return $this->eat8();<br />			}<br /><br />function estimateBitsModeNum($size) {<br />		$w = (int)$size / 3;<br />		$bits = $w * 10;<br />		switch($size - $w * 3) {<br />			case 1: {<br />				$bits += 4;<br />				break;<br />			}<br />			case 2: {<br />				$bits += 7;<br />				break;<br />			}<br />			default: {<br />				break;<br />			}<br />		}<br />		return $bits;<br />	}<br /><br />function estimateBitsMode8($size) {<br />		return $size * 8;<br />	}<br /><br /><br />function lengthIndicator($mode, $version) {<br />		if ($mode == $this->QR_MODE_ST) {<br />			return 0;<br />		}<br />		if ($version <= 9) {<br />			$l = 0;<br />		} elseif ($version <= 26) {<br />			$l = 1;<br />		} else {<br />			$l = 2;<br />		}<br />		return $this->lengthTableBits[$mode][$l];<br />	}<br /><br />$lengthTableBits = array(<br />		array(10, 12, 14),<br />		array( 9, 11, 13),<br />		array( 8, 16, 16),<br />		array( 8, 10, 12)<br />	);

------解决方案--------------------
不懂二维码的原理,看代码能看懂么?
Numeric mode 数字编码,从0到9。如果需要编码的数字的个数不是3的倍数,那么,最后剩下的1或2位数会被转成4或7bits,则其它的每3位数字会被编成 10,12,14bits    对应你的estimateBitsModeNum
不同version下编码的位数:
对应你的lengthIndicator

我也不懂,帮你找的资料: http://coolshell.cn/articles/10590.html#jtss-tsina

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn