From 83f926758cce83b081fc6b14026bf8bcd0baeeaf Mon Sep 17 00:00:00 2001 From: Michael Billington Date: Sun, 11 Sep 2016 21:06:44 +1000 Subject: [PATCH] adjust order in _encode_char to prioritise ASCII; ' ' is used in the character list to flag characters with no known UTF-8 code, better not encode as these --- src/escpos/magicencode.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/escpos/magicencode.py b/src/escpos/magicencode.py index 764b05f..d48d59d 100644 --- a/src/escpos/magicencode.py +++ b/src/escpos/magicencode.py @@ -132,10 +132,10 @@ class Encoder(object): :param char: char to encode :param charmap: dictionary for mapping characters in this code page """ - if char in charmap: - return charmap[char] if ord(char) < 128: return ord(char) + if char in charmap: + return charmap[char] return ord('?') def encode(self, text, encoding, defaultchar='?'):