Closed jplevene closed 3 years ago
Looking at this, to be honest it would probably be safer to use mb_substr or substr.
Not sure which barcodes support multibyte chars as this code seems only to support single byte upto chr(127), but using $string[$index] will not get the entire char for UTF8 strings as it will only get one byte and not the 2 bytes used to make up the character
It looks like you are using a very old version of this library. Please update to the latest version, which works and is tested on PHP 8.
The curly braces to index a character no longer works so the following code works in PHP7 & PHP8 (not checked in PHP5.4). This replaces the file BarcodeGenereator.php
`<?php
/**
// Copyright (C) 2002-2015 Nicola Asuni - Tecnick.com LTD // // This file is part of TCPDF software library. // // TCPDF is free software: you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // TCPDF is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // See the GNU Lesser General Public License for more details. // // You should have received a copy of the License // along with TCPDF. If not, see // http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT. // // See LICENSE.TXT file for more information.
namespace Picqer\Barcode;
use Picqer\Barcode\Exceptions\BarcodeException; use Picqer\Barcode\Exceptions\InvalidCharacterException; use Picqer\Barcode\Exceptions\InvalidCheckDigitException; use Picqer\Barcode\Exceptions\InvalidFormatException; use Picqer\Barcode\Exceptions\InvalidLengthException; use Picqer\Barcode\Exceptions\UnknownTypeException;
abstract class BarcodeGenerator { const TYPE_CODE_39 = 'C39'; const TYPE_CODE_39_CHECKSUM = 'C39+'; const TYPE_CODE_39E = 'C39E'; const TYPE_CODE_39E_CHECKSUM = 'C39E+'; const TYPE_CODE_93 = 'C93'; const TYPE_STANDARD_2_5 = 'S25'; const TYPE_STANDARD_2_5_CHECKSUM = 'S25+'; const TYPE_INTERLEAVED_2_5 = 'I25'; const TYPE_INTERLEAVED_2_5_CHECKSUM = 'I25+'; const TYPE_CODE_128 = 'C128'; const TYPE_CODE_128_A = 'C128A'; const TYPE_CODE_128_B = 'C128B'; const TYPE_CODE_128_C = 'C128C'; const TYPE_EAN_2 = 'EAN2'; const TYPE_EAN_5 = 'EAN5'; const TYPE_EAN_8 = 'EAN8'; const TYPE_EAN_13 = 'EAN13'; const TYPE_UPC_A = 'UPCA'; const TYPE_UPC_E = 'UPCE'; const TYPE_MSI = 'MSI'; const TYPE_MSI_CHECKSUM = 'MSI+'; const TYPE_POSTNET = 'POSTNET'; const TYPE_PLANET = 'PLANET'; const TYPE_RMS4CC = 'RMS4CC'; const TYPE_KIX = 'KIX'; const TYPE_IMB = 'IMB'; const TYPE_CODABAR = 'CODABAR'; const TYPE_CODE_11 = 'CODE11'; const TYPE_PHARMA_CODE = 'PHARMA'; const TYPE_PHARMA_CODE_TWO_TRACKS = 'PHARMA2T';
} `