andrey-ushakov / esc_pos_utils

Basic Flutter/Dart classes for ESC/POS printing
BSD 3-Clause "New" or "Revised" License
151 stars 339 forks source link

How can I print Thai language? #77

Open KhomsanSaejia opened 2 years ago

KhomsanSaejia commented 2 years ago

image

waqadArshad commented 1 year ago

Hi, it's very easy to support utf8 encoding which would help you print many languages. You just have to add an entry in the default section of capabilities.json and if you don't want to bother with that, you can use my fork:

https://github.com/waqadArshad/esc_pos_utils

as:

  esc_pos_utils:
    git:
      url: https://github.com/waqadArshad/esc_pos_utils.git

and if it fixes your issue, please remember to STAR the repo.

thitlwincoder commented 1 year ago

@waqadArshad Hi, I try with this. but still not working.

this is my code.

final profile = await CapabilityProfile.load();
final generator = Generator(PaperSize.mm80, profile);
bytes += generator.setGlobalCodeTable('UTF-8');

var encode = await CharsetConverter.encode('UTF-8', 'မြန်မာစာ');
bytes += generator.textEncoded(encode);
// or
var encode = Uint8List.fromList(utf8.encode('မြန်မာစာ'));
bytes += generator.textEncoded(encode);

this is print result IMG_20230913_134715

waqadArshad commented 1 year ago

Hi, can you please check if your printer is set to UTF-8 encoding or not?

thitlwincoder commented 1 year ago

@waqadArshad printer Selfttest page show

Current character:
                   Chinese(GB18030)
                   Alphanumeric
waqadArshad commented 1 year ago

then change this. there must be more encodings available.