BarcodeGenerator::upc_e_encode

  1. Bitrix24 API (v. 23.675.0)
  2. ui
  3. BarcodeGenerator
  4. upc_e_encode
  • Модуль: ui
  • Путь к файлу: ~/bitrix/modules/ui/lib/barcode/barcodegenerator.php
  • Класс: BitrixUIBarcodeBarcodeGenerator
  • Вызов: BarcodeGenerator::upc_e_encode
private function upc_e_encode($data) {
	$data = $this->upc_e_normalize($data);
	$blocks = array();
	/* Quiet zone, start. */
	$blocks[] = array(
		'm' => array(array(0, 9, 0))
	);
	$blocks[] = array(
		'm' => array(
			array(1, 1, 1),
			array(0, 1, 1),
			array(1, 1, 1),
		)
	);
	/* Digits */
	$system = substr($data, 0, 1) & 1;
	$check = substr($data, 7, 1);
	$pbits = $this->upc_parity[$check];
	for ($i = 1; $i < 7; $i++) {
		$digit = substr($data, $i, 1);
		$pbit = $pbits[$i - 1] ^ $system;
		$blocks[] = array(
			'm' => array(
				array(0, $this->upc_alphabet[$digit][$pbit ? 3 : 0], 1),
				array(1, $this->upc_alphabet[$digit][$pbit ? 2 : 1], 1),
				array(0, $this->upc_alphabet[$digit][$pbit ? 1 : 2], 1),
				array(1, $this->upc_alphabet[$digit][$pbit ? 0 : 3], 1),
			),
			'l' => array($digit, 0.5, (7 - $i) / 7)
		);
	}
	/* End, quiet zone. */
	$blocks[] = array(
		'm' => array(
			array(0, 1, 1),
			array(1, 1, 1),
			array(0, 1, 1),
			array(1, 1, 1),
			array(0, 1, 1),
			array(1, 1, 1),
		)
	);
	$blocks[] = array(
		'm' => array(array(0, 9, 0))
	);
	/* Return code. */
	return array('g' => 'l', 'b' => $blocks);
}

Добавить комментарий