diff --git a/datamatrix.php b/datamatrix.php index 28208c4..8839486 100755 --- a/datamatrix.php +++ b/datamatrix.php @@ -1,9 +1,9 @@ isCharMode($chr, ENC_ASCII_NUM)) { @@ -709,7 +709,7 @@ class Datamatrix { while ($pos < $data_lenght) { switch ($enc) { case ENC_ASCII: { // STEP B. While in ASCII encodation - if (($data_lenght > 1) AND ($pos < ($data_lenght - 1)) AND ($this->isCharMode(ord($data{($pos)}), ENC_ASCII_NUM) AND $this->isCharMode(ord($data{($pos + 1)}), ENC_ASCII_NUM))) { + if (($data_lenght > 1) AND ($pos < ($data_lenght - 1)) AND ($this->isCharMode(ord($data[$pos]), ENC_ASCII_NUM) AND $this->isCharMode(ord($data[$pos + 1]), ENC_ASCII_NUM))) { // 1. If the next data sequence is at least 2 consecutive digits, encode the next two digits as a double digit in ASCII mode. $cw[] = (intval(substr($data, $pos, 2)) + 130); ++$cw_num; @@ -724,7 +724,7 @@ class Datamatrix { ++$cw_num; } else { // get new byte - $chr = ord($data{($pos)}); + $chr = ord($data[$pos]); ++$pos; if ($this->isCharMode($chr, ENC_ASCII_EXT)) { // 3. If the next data character is extended ASCII (greater than 127) encode it in ASCII mode first using the Upper Shift (value 235) character. @@ -752,7 +752,7 @@ class Datamatrix { $charset = $this->chset[$set_id]; do { // 2. process the next character in C40 encodation. - $chr = ord($data{($epos)}); + $chr = ord($data[$epos]); ++$epos; // check for extended character if ($chr & 0x80) { @@ -802,6 +802,8 @@ class Datamatrix { $enc = $newenc; $cw[] = $this->getSwitchEncodingCodeword($enc); ++$cw_num; + $pos -= $p; + $p = 0; break; } } @@ -834,9 +836,11 @@ class Datamatrix { $cw_num += 2; } else { // switch to ASCII encoding - $enc = ENC_ASCII; - $cw[] = $this->getSwitchEncodingCodeword($enc); - ++$cw_num; + if ($enc != ENC_ASCII) { + $enc = ENC_ASCII; + $cw[] = $this->getSwitchEncodingCodeword($enc); + ++$cw_num; + } } } break; @@ -846,52 +850,50 @@ class Datamatrix { $temp_cw = array(); $epos = $pos; $field_lenght = 0; - while ($epos < $data_lenght) { + $newenc = $enc; + do { // 2. process the next character in EDIFACT encodation. - $chr = ord($data{($epos)}); - ++$epos; - $temp_cw[] = $chr; - ++$field_lenght; - if (($field_lenght == 4) OR ($epos == $data_lenght)) { - if ($field_lenght < 4) { + $chr = ord($data[$epos]); + if ($this->isCharMode($chr, ENC_EDF)) { + ++$epos; + $temp_cw[] = $chr; + ++$field_lenght; + } + if (($field_lenght == 4) OR ($epos == $data_lenght) OR !$this->isCharMode($chr, ENC_EDF)) { + if ($field_lenght < 4) { echo $field_lenght."\n"; // set unlatch character $temp_cw[] = 0x1f; ++$field_lenght; - $enc = ENC_ASCII; // fill empty characters for ($i = $field_lenght; $i < 4; ++$i) { $temp_cw[] = 0; } + $enc = ENC_ASCII; } // encodes four data characters in three codewords - $cw[] = (($temp_cw[0] & 0x3F) << 2) + (($temp_cw[1] & 0x30) >> 4); - $cw[] = (($temp_cw[1] & 0x0F) << 4) + (($temp_cw[2] & 0x3C) >> 2); - $cw[] = (($temp_cw[2] & 0x03) << 6) + ($temp_cw[3] & 0x3F); - $cw_num += 3; + $tcw = (($temp_cw[0] & 0x3F) << 2) + (($temp_cw[1] & 0x30) >> 4); + if ($tcw > 0) { + $cw[] = $tcw; + $cw_num++; + } + $tcw= (($temp_cw[1] & 0x0F) << 4) + (($temp_cw[2] & 0x3C) >> 2); + if ($tcw > 0) { + $cw[] = $tcw; + $cw_num++; + } + $tcw = (($temp_cw[2] & 0x03) << 6) + ($temp_cw[3] & 0x3F); + if ($tcw > 0) { + $cw[] = $tcw; + $cw_num++; + } $temp_cw = array(); $pos = $epos; $field_lenght = 0; - } - } - // 1. If the EDIFACT encoding is at the point of starting a new triple symbol character and if the look-ahead test (starting at step J) indicates another mode, switch to that mode. - if ($field_lenght == 0) { - // get remaining number of data symbols - $cwr = ($this->getMaxDataCodewords($cw_num + 2) - $cw_num); - if ($cwr < 3) { - // return to ascii without unlatch - $enc = ENC_ASCII; - break; // exit from EDIFACT mode - } else { - $newenc = $this->lookAheadTest($data, $pos, $enc); - if ($newenc != $enc) { - // 1. If the look-ahead test (starting at step J) indicates another mode, switch to that mode. - $enc = $newenc; - $cw[] = $this->getSwitchEncodingCodeword($enc); - ++$cw_num; + if ($enc == ENC_ASCII) { break; // exit from EDIFACT mode } } - } + } while ($epos < $data_lenght); break; } case ENC_BASE256: { // G. While in Base 256 (B256) encodation @@ -908,7 +910,7 @@ class Datamatrix { break; // exit from B256 mode } else { // 2. Otherwise, process the next character in Base 256 encodation. - $chr = ord($data{($pos)}); + $chr = ord($data[$pos]); ++$pos; $temp_cw[] = $chr; ++$field_lenght; diff --git a/tcpdf.php b/tcpdf.php index 45c032a..00be28f 100755 --- a/tcpdf.php +++ b/tcpdf.php @@ -1,9 +1,9 @@ * @package com.tecnick.tcpdf * @author Nicola Asuni - * @version 5.9.197 + * @version 5.9.198 */ // Main configuration file. Define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file. @@ -151,7 +151,7 @@ require_once(dirname(__FILE__).'/config/tcpdf_config.php'); * TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.
* @package com.tecnick.tcpdf * @brief PHP class for generating PDF documents without requiring external extensions. - * @version 5.9.197 + * @version 5.9.198 * @author Nicola Asuni - info@tecnick.com */ class TCPDF { @@ -162,7 +162,7 @@ class TCPDF { * Current TCPDF version. * @private */ - private $tcpdf_version = '5.9.197'; + private $tcpdf_version = '5.9.198'; // Protected properties