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

allow encoding non-latin characters in a ticket #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/src/ticket.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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)
Expand Down Expand Up @@ -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));
}
Expand Down