Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special Character print issue. #15

Open
mjafartp opened this issue May 26, 2020 · 5 comments
Open

Special Character print issue. #15

mjafartp opened this issue May 26, 2020 · 5 comments

Comments

@mjafartp
Copy link

mjafartp commented May 26, 2020

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)
@sbrsubuvga
Copy link

i have also the same issue

tried PosColumn( textEncoded: utf8.encode(NumberFormat.simpleCurrency(name: 'INR').currencySymbol),width: 4)

but it print wrong character

@rv786
Copy link

rv786 commented Jul 12, 2020

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: special-character-print-issue-resolved

@sbrsubuvga
Copy link

sbrsubuvga commented Jul 14, 2020

@rv786 PosCodeTable not found.

@ayushin
Copy link

ayushin commented Jul 18, 2020

I've just made a #22 that allows you to use a custom text encoder also outside of Row/Column scenario

@rv786
Copy link

rv786 commented Jul 19, 2020

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants