1
0
mirror of https://github.com/python-escpos/python-escpos synced 2025-08-24 09:03:34 +00:00

Magic encoder: fix codepage usage (#580)

* add unit test for issue pointed out by @scott-r in #570

* swap order of encoder search

As described by @scott-r in
Magic encoder does not use
previously used code pages
when possible #570
Thank you!
This commit is contained in:
Patrick Kanzler
2023-10-05 14:55:12 +02:00
committed by GitHub
parent 5018f7f377
commit a70e1604d6
4 changed files with 14 additions and 1 deletions

View File

@@ -155,7 +155,8 @@ class Encoder(object):
def __encoding_sort_func(self, item):
key, index = item
return (key in self.used_encodings, index)
used = key in self.used_encodings
return (not used, index)
def find_suitable_encoding(self, char):
"""Search in a specific order for a suitable encoding.