Although a recent pull request (https://github.com/Bacon/BaconQrCode/pull/170) fixed encoding errors for Shift-JIS, generating QR codes in Kanji mode still presents issues with readability. For instance, attempting to generate a QR code using only Kanji characters results in an unreadable code.
For Kanji Mode example:
use BaconQrCode\Renderer\ImageRenderer;
use BaconQrCode\Renderer\Image\ImagickImageBackEnd;
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
use BaconQrCode\Writer;
$renderer = new ImageRenderer(
new RendererStyle(400),
new ImagickImageBackEnd()
);
$writer = new Writer($renderer);
$writer->writeFile("あいうえお", "qrcode-alphanum.png", "SHIFT-JIS"); // Kanji Mode is used
Generated QR code (unreadable)
However, by including alphanumeric characters and switching to Byte mode, a readable QR code can be generated.
For Byte Mode example:
use BaconQrCode\Renderer\ImageRenderer;
use BaconQrCode\Renderer\Image\ImagickImageBackEnd;
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
use BaconQrCode\Writer;
$renderer = new ImageRenderer(
new RendererStyle(400),
new ImagickImageBackEnd()
);
$writer = new Writer($renderer);
$writer->writeFile("あいうえお123", "qrcode-alphanum.png", "SHIFT-JIS"); // Byte Mode is used
Generated QR code (readable)
How to fix:
I think we should just simply use Byte Mode to generate Shift-JIS encoded QR Code by changing this code:
Although a recent pull request (https://github.com/Bacon/BaconQrCode/pull/170) fixed encoding errors for Shift-JIS, generating QR codes in Kanji mode still presents issues with readability. For instance, attempting to generate a QR code using only Kanji characters results in an unreadable code.
For Kanji Mode example:
Generated QR code (unreadable)
However, by including alphanumeric characters and switching to Byte mode, a readable QR code can be generated.
For Byte Mode example:
Generated QR code (readable)
How to fix:
I think we should just simply use Byte Mode to generate Shift-JIS encoded QR Code by changing this code:
https://github.com/Bacon/BaconQrCode/blob/c01758cc4bf2eb4225b92dae7d766c1a4b069185/src/Encoder/Encoder.php#L165-L167
to this: