- Модуль: ui
- Путь к файлу: ~/bitrix/modules/ui/lib/barcode/barcodegenerator.php
- Класс: BitrixUIBarcodeBarcodeGenerator
- Вызов: BarcodeGenerator::qr_encode_alphanumeric
private function qr_encode_alphanumeric($data, $version_group) {
$alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:';
$code = array(0, 0, 1, 0);
$length = strlen($data);
switch ($version_group) {
case 2: /* 27 - 40 */
$code[] = $length & 0x1000;
$code[] = $length & 0x0800;
case 1: /* 10 - 26 */
$code[] = $length & 0x0400;
$code[] = $length & 0x0200;
case 0: /* 1 - 9 */
$code[] = $length & 0x0100;
$code[] = $length & 0x0080;
$code[] = $length & 0x0040;
$code[] = $length & 0x0020;
$code[] = $length & 0x0010;
$code[] = $length & 0x0008;
$code[] = $length & 0x0004;
$code[] = $length & 0x0002;
$code[] = $length & 0x0001;
}
for ($i = 0; $i < $length; $i += 2) {
$group = substr($data, $i, 2);
if (strlen($group) > 1) {
$c1 = strpos($alphabet, substr($group, 0, 1));
$c2 = strpos($alphabet, substr($group, 1, 1));
$ch = $c1 * 45 + $c2;
$code[] = $ch & 0x400;
$code[] = $ch & 0x200;
$code[] = $ch & 0x100;
$code[] = $ch & 0x080;
$code[] = $ch & 0x040;
$code[] = $ch & 0x020;
$code[] = $ch & 0x010;
$code[] = $ch & 0x008;
$code[] = $ch & 0x004;
$code[] = $ch & 0x002;
$code[] = $ch & 0x001;
} else {
$ch = strpos($alphabet, $group);
$code[] = $ch & 0x020;
$code[] = $ch & 0x010;
$code[] = $ch & 0x008;
$code[] = $ch & 0x004;
$code[] = $ch & 0x002;
$code[] = $ch & 0x001;
}
}
return $code;
}