mirror of
https://github.com/python-escpos/python-escpos
synced 2025-09-13 09:09:58 +00:00
re-work encoder to consult the capabilities database and use custom code pages or python encoder as necessary
This commit is contained in:
@@ -12,21 +12,11 @@ class CodePageManager:
|
||||
def get_all(self):
|
||||
return self.data.values()
|
||||
|
||||
def encode(self, text, encoding, errors='strict'):
|
||||
"""Adds support for Japanese to the builtin str.encode().
|
||||
|
||||
TODO: Add support for custom code page data from
|
||||
escpos-printer-db.
|
||||
"""
|
||||
# Python has not have this builtin?
|
||||
if encoding.upper() == 'KATAKANA':
|
||||
return encode_katakana(text)
|
||||
|
||||
return text.encode(encoding, errors=errors)
|
||||
def get_encoding_name(self, encoding):
|
||||
# TODO resolve the encoding alias
|
||||
return encoding.upper()
|
||||
|
||||
def get_encoding(self, encoding):
|
||||
# resolve the encoding alias
|
||||
return encoding.lower()
|
||||
|
||||
return self.data[encoding]
|
||||
|
||||
CodePages = CodePageManager(CAPABILITIES['encodings'])
|
Reference in New Issue
Block a user