kakzaki / blue_thermal_printer

Working with thermal printer via bluetooth (Flutter)
MIT License
166 stars 211 forks source link

Flutter Print UTF-8 (Vietnamese) on bluetooth thermal printer using “blue_thermal_printer 1.1.3” #76

Closed anpham293 closed 3 years ago

tcd93 commented 3 years ago

This also depends on your printer, not every printer support UTF-8 encoding

Vietnamese restaurants usually use SUNMI POS printer which DOES support it, but it does not follow the ESC/POS standard command

You have to customize your print methods such as printLeftRight to input special command before writing:

// PrinterCommands.java
static final byte[] ENC_UTF8 = new byte[] {0x1C, 0x43, (byte) 0xFF}; // SUMMI printer specific codes
...
THREAD.write(PrinterCommands.ENC_UTF8); // add this line before writing

This is the link to the developer guide of SUNMI: https://file.cdn.sunmi.com/SUNMIDOCS/Sunmi-Printing-Service-ENCN.pdf

For ESC/POS compliant devices the command hex code is 1C 28 43 02 00 30 m (FS ( C, m depends on the model)

JRakhimov commented 3 years ago

@tcd93 Hi, can you help, please, how to print cyrillic symbols? Printer model

tcd93 commented 3 years ago

@JRakhimov Took a look in the description and seems like it support cyrillic characters

Try adding the command 1B, 74, 17

// PrinterCommands.java
static final byte[] ENC_CYRIL = new byte[] {0x1B, 0x74, 0x17};
...
// in PrintLeftRight, add this to the begining
Thread.Write(PrinterCommands.ENC_CYRIL)

image

JRakhimov commented 3 years ago

@tcd93 Amazing, works great, thank you

JRakhimov commented 3 years ago

P.S. charset should be "windows-1251"

ebrahimmansur commented 3 years ago

This also depends on your printer, not every printer support UTF-8 encoding

Vietnamese restaurants usually use SUNMI POS printer which DOES support it, but it does not follow the ESC/POS standard command

You have to customize your print methods such as printLeftRight to input special command before writing:

// PrinterCommands.java
static final byte[] ENC_UTF8 = new byte[] {0x1C, 0x43, (byte) 0xFF}; // SUMMI printer specific codes
...
THREAD.write(PrinterCommands.ENC_UTF8); // add this line before writing

This is the link to the developer guide of SUNMI: https://file.cdn.sunmi.com/SUNMIDOCS/Sunmi-Printing-Service-ENCN.pdf

For ESC/POS compliant devices the command hex code is 1C 28 43 02 00 30 m (FS ( C, m depends on the model)

where is this code implemented -> which file