esc_pos_utils icon indicating copy to clipboard operation
esc_pos_utils copied to clipboard

Printing on other languages

Open nikolajocic opened this issue 2 years ago • 6 comments

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

nikolajocic avatar Sep 01 '22 15:09 nikolajocic

hey @nikolajocic did you find a solution?

niyonx avatar Sep 06 '22 14:09 niyonx

did you find a solution?

xaldarof avatar Sep 13 '22 11:09 xaldarof

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

vipros123 avatar Sep 13 '22 11:09 vipros123

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

@vipros123 how to use it with utf8?

anhhtbk avatar Sep 28 '22 02:09 anhhtbk

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

BrunoSantosCosta avatar Jan 06 '23 13:01 BrunoSantosCosta

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

waqadArshad avatar Jul 22 '23 23:07 waqadArshad