mtmsuhail / ESC-POS-USB-NET

This project is a simple .NET (C#) Implementation of the Epson ESC/POS Printing using USB Device Driver.
MIT License
202 stars 86 forks source link

Encode QRCode with ISO-8859-1, instead of UTF8 #31

Open ialexj opened 3 years ago

ialexj commented 3 years ago

Hi,

I'm having an issue printing QRCodes that have certain accented characters, such as "Ó". The printer I'm using simply renders a single T instead of the code, when these characters are used.

I've determined that the printer works fine if the data is encoded in ISO-8859-1 rather than UTF8. According to this StackOverflow thread, ISO-8859-1 should be the default, as UTF8 is only supported through an extension.

https://stackoverflow.com/questions/51516612/choosing-a-character-encoding-for-qr-codes

I would suggest changing:

https://github.com/mtmsuhail/ESC-POS-USB-NET/blob/2de903957145a6f564d9a9eda0612356dd19c6a5/ESC-POS-USB-NET/Epson%20Commands/QrCode.cs#L56

to

list.AddRange(Encoding.GetEncoding("ISO-8859-1").GetBytes(qrData));

That fixes the issue for me.

Thanks, Alex J.