From 2bd7c8e5ce729db1f8ed77248aad3b13e5a06d8b Mon Sep 17 00:00:00 2001 From: Alexey Yushin Date: Sat, 18 Jul 2020 09:30:11 +0200 Subject: [PATCH] allow encoding non-latin characters in a ticket --- lib/src/ticket.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/src/ticket.dart b/lib/src/ticket.dart index e96da95..2135771 100644 --- a/lib/src/ticket.dart +++ b/lib/src/ticket.dart @@ -20,7 +20,7 @@ import 'pos_styles.dart'; import 'qrcode.dart'; class Ticket { - Ticket(this._paperSize, this._profile) { + Ticket(this._paperSize, this._profile, {codec = latin1}) : this._codec = codec { reset(); } @@ -35,6 +35,7 @@ class Ticket { PosFontType _font; // Current styles PosStyles _styles = PosStyles(); + final Codec _codec; /// Set global code table which will be used instead of the default printer's code table /// (even after resetting) @@ -66,7 +67,7 @@ class Ticket { Uint8List _encode(String text, {bool isKanji = false}) { if (!isKanji) { - return latin1.encode(text); + return _codec.encode(text); } else { return Uint8List.fromList(gbk_bytes.encode(text)); }