esc_pos_utils
esc_pos_utils copied to clipboard
Special Character print issue.
Ca't print Special characters like currency symbol
like NumberFormat.simpleCurrency(name: 'INR').currencySymbol
as String ₹
error:
[ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: Invalid argument (string): Contains invalid characters.: "₹102.90"
E/flutter ( 1978): #0 _UnicodeSubsetEncoder.convert (dart:convert/ascii.dart:88:9)
E/flutter ( 1978): #1 Latin1Codec.encode (dart:convert/latin1.dart:42:46)
E/flutter ( 1978): #2 Ticket._encode (package:esc_pos_utils/src/ticket.dart:67:21)
i have also the same issue
tried PosColumn( textEncoded: utf8.encode(NumberFormat.simpleCurrency(name: 'INR').currencySymbol),width: 4)
but it print wrong character
I found the solution
ticket.row([ PosColumn(text: 'Total:', width: 6), PosColumn( width: 6, styles: PosStyles(align: PosAlign.right,codeTable: PosCodeTable.westEur), textEncoded: Uint8List.fromList([128]+"130.00".codeUnits) ), ]);
I am researching and found its use ASCII Decimal Code list https://www.ascii-code.com/#extendedASCIIDescription As Example, I use Euro sign(€) which ASCII Decimal Code is 128
DEC | OCT | HEX | BIN | Symbol | HTML Number | HTML Name | Description 128 | 200 | 80 | 10000000 | € | € | € | Euro sign
"102.90".codeUnits
codeUnits return an unmodifiable list of the UTF-16 code units of this string. https://api.flutter.dev/flutter/dart-core/String-class.html#codeUnits
Result:
@rv786 PosCodeTable
not found.
I've just made a https://github.com/andrey-ushakov/esc_pos_utils/pull/22 that allows you to use a custom text encoder also outside of Row/Column scenario
@sbrsubuvga if you are use esc_pos_bluetooth package then make sure you use these esc_pos_utils: ^0.3.6
in your pubspec.yaml file
esc_pos_bluetooth: ^0.2.8
esc_pos_utils: ^0.3.6
and if you try to use esc_pos_utils: ^0.4.5
then you can get this message Because esc_pos_bluetooth 0.2.8 depends on esc_pos_utils ^0.3.6 and no versions of esc_pos_bluetooth match >0.2.8 <0.3.0, esc_pos_bluetooth ^0.2.8 requires esc_pos_utils ^0.3.6.