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

Add Chinese support (#356)

* Add Chinese support

* Add author

* Add newline

* Revert "Add Chinese support"

This reverts commit 110200dde6.

* Add Chinese support

* Add Chinese support

* update mailmap file

* update formatting

---------

Co-authored-by: Patrick Kanzler <dev@pkanzler.de>
Co-authored-by: Patrick Kanzler <4189642+patkan@users.noreply.github.com>
This commit is contained in:
白月秋见心
2023-05-09 07:18:00 +08:00
committed by GitHub
parent 25867f3196
commit 6849dd3979
3 changed files with 7 additions and 0 deletions

View File

@@ -18,6 +18,7 @@ from .constants import CODEPAGE_CHANGE
from .exceptions import Error
from .codepages import CodePages
import six
import re
class Encoder(object):
@@ -252,6 +253,10 @@ class MagicEncode(object):
self.write_with_encoding(self.encoding, text)
return
if re.findall(r"[\u4e00-\u9fa5]", text):
self.driver._raw(text.encode("GB18030"))
return
# See how far we can go into the text with the current encoding
to_write, text = split_writable_text(self.encoder, text, self.encoding)
if to_write: