Bacon / BaconQrCode

QR Code Generator for PHP
BSD 2-Clause "Simplified" License
1.82k stars 208 forks source link

BaconQrCode does not work correctly with Cyrillic alphabet. #151

Closed Bramfield closed 5 months ago

Bramfield commented 10 months ago

Hello! I have a problem... I create a QR code for my clients in product invoices. The recipient and description of the payment must appear in Cyrillic, but not all banks recognize it. There are no problems with the Latin alphabet, any bank accepts this QR code (UTF-8 file format without BOM):

<?php
require 'vendor/autoload.php';

use BaconQrCode\Renderer\RendererStyle\RendererStyle;
use BaconQrCode\Renderer\ImageRenderer;
use BaconQrCode\Writer;
use BaconQrCode\Renderer\Image\ImagickImageBackEnd;

$name = "Cyrillic";
$bankAccount = "UA01234567890987654321";
$amount = "1000.99";
$currency = "UAH";
$code = "1234567890";
$description = "Cyrillic";
$base64code = base64_encode("BCD\n002\n2\nUCT\n\n{$name}\n{$bankAccount}\n{$currency}{$amount}\n{$code}\n\n\n{ $description}\n\n");
$qrText = "https://bank.dot.com/qr/".$base64code;

$renderer = new ImageRenderer(
     new RendererStyle(200),
     new ImagickImageBackEnd()
);

$writer = new Writer($renderer);

$filename = "qr_code.png";
$writer->writeFile($qrText, $filename);

header('Content-Type: image/png');
readfile($filename);

//echo "QR code generated!";
?>

Please help me solve the problem.

arxeiss commented 9 months ago

I don't understand what doesn't work for you. If you have Cyrilic characters in $description and then you use base64_encode you get only latin characters anyway. Where the QR code fail with Cyrilic characters?