Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binary encoder fails if over 31 chars #12

Open
bozhinov opened this issue Nov 20, 2019 · 1 comment
Open

Binary encoder fails if over 31 chars #12

bozhinov opened this issue Nov 20, 2019 · 1 comment

Comments

@bozhinov
Copy link

bozhinov commented Nov 20, 2019

`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

@artemvd
Copy link

artemvd commented Nov 26, 2020

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants