metzli icon indicating copy to clipboard operation
metzli copied to clipboard

Binary encoder fails if over 31 chars

Open bozhinov opened this issue 5 years ago • 1 comments

`require 'bootstrap.php';

use Metzli\Encoder\Encoder; use Metzli\Encoder\DataEncoder\BinaryDataEncoder; use Metzli\Renderer\PngRenderer;

$encoder = new BinaryDataEncoder();

$code = Encoder::encode(str_repeat("a", 50), 33, $encoder); $renderer = new PngRenderer();

file_put_contents("test.png", $renderer->render($code)); ` The barcode scanner says there is an extra KF at the end of the string

bozhinov avatar Nov 20 '19 09:11 bozhinov

I had the same issue, the solution implemented in @bozhinov saved my day.

Line 35 in src/Metzli/Encoder/DataEncoder/BinaryDataEncoder.php should be:

$result->append(($chunkLength - 31), 11);

instead of:

$result->append(($chunkLength - 32), 11);

For me it caused the errorous byte. Complete message was correct except for 1 byte.

Should I create MR for it?

artemvd avatar Nov 26 '20 16:11 artemvd