Add Chinese support
This commit is contained in:
parent
3dc88794c2
commit
1db55caba8
@ -22,6 +22,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,9 @@ 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):
|
||||||
|
text = text.encode('GB18030')
|
||||||
|
|
||||||
# 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:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user