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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 0 deletions

View File

@ -13,6 +13,7 @@ csoft2k <csoft2k@hotmail.com>
Sergio Pulgarin <sergio.pulgarin@gmail.com> Sergio Pulgarin <sergio.pulgarin@gmail.com>
reck31 <rakesh.gunduka@gmail.com> reck31 <rakesh.gunduka@gmail.com>
Alex Debiasio <alex.debiasio@thinkin.io> <alex.debiasio@studenti.unitn.it> Alex Debiasio <alex.debiasio@thinkin.io> <alex.debiasio@studenti.unitn.it>
白月秋见心 <ourweijiang@gmail.com>
Maximilian Wagenbach <maximilian.wagenbach@native-instruments.de> Maximilian Wagenbach <maximilian.wagenbach@native-instruments.de>
<belono@users.noreply.github.com> <tiotil.lindeman@gmail.com> <belono@users.noreply.github.com> <tiotil.lindeman@gmail.com>
belono <belono@users.noreply.github.com> Benito López <belono@users.noreply.github.com> belono <belono@users.noreply.github.com> Benito López <belono@users.noreply.github.com>

View File

@ -41,3 +41,4 @@ Thijs Triemstra
Thomas van den Berg Thomas van den Berg
Yaisel Hurtado Yaisel Hurtado
ysuolmai ysuolmai
白月秋见心

View File

@ -18,6 +18,7 @@ from .constants import CODEPAGE_CHANGE
from .exceptions import Error from .exceptions import Error
from .codepages import CodePages from .codepages import CodePages
import six import six
import re
class Encoder(object): class Encoder(object):
@ -252,6 +253,10 @@ class MagicEncode(object):
self.write_with_encoding(self.encoding, text) self.write_with_encoding(self.encoding, text)
return 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 # See how far we can go into the text with the current encoding
to_write, text = split_writable_text(self.encoder, text, self.encoding) to_write, text = split_writable_text(self.encoder, text, self.encoding)
if to_write: if to_write: