andrey-ushakov / esc_pos_utils

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

Printing on other languages #82

Open nikolajocic opened 1 year ago

nikolajocic commented 1 year ago

Hi. Great job.

When we try to print Serbian (Eastern Europe languages CP1251, CP852, CP855. ), we got exception. We check 2 printers (with other programs it works great), and both support those CP.

Code:

bytes += generator.text('Test Print', styles: const PosStyles(align: PosAlign.center));
    bytes += generator.text('Product 1');
    bytes += generator.text('Product 2');
    bytes += generator.text('šđžčć ŠĐŽČĆ', styles: const PosStyles(codeTable: 'CP1251'));  // Latin2, Eastern Europe
    bytes += generator.text('шђжчћљњ ШЂЖЧЋЉЊ ', styles: const PosStyles(codeTable: 'CP855')); // Cyrilic, Eastern Europe

Error:

[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: Invalid argument (string): Contains invalid characters.: "šđžčć ŠĐŽČĆ"
#0      _UnicodeSubsetEncoder.convert (dart:convert/ascii.dart:85:9)
#1      Latin1Codec.encode (dart:convert/latin1.dart:40:46)
#2      Generator._encode (package:esc_pos_utils/src/generator.dart:77:21)
#3      Generator.text (package:esc_pos_utils/src/generator.dart:354:9)
#4      _MyAppState._printReceiveTest (package:f_flutter_pos_printer_platform_3/main.dart:162:24)
<asynchronous suspension>

Our printer capabilities where you can se supported CPs: 1662046711831

niyonx commented 1 year ago

hey @nikolajocic did you find a solution?

xaldarof commented 1 year ago

did you find a solution?

vipros123 commented 1 year ago

Use Plugin https://pub.dev/packages/flutter_esc_pos_utils with codec utf8

anhhtbk commented 1 year ago

Use Plugin https://pub.dev/packages/flutter_esc_pos_utils with codec utf8

@vipros123 how to use it with utf8?

BrunoSantosCosta commented 1 year ago

how you use utf8 this package? https://pub.dev/packages/flutter_esc_pos_utils

waqadArshad commented 1 year ago

Hi, it's very easy to support utf8 encoding. 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