提交 e5d040a2 编写于 作者: M Mort Yao

print Unicode strings on codepage where possible

上级 82f2b8d4
......@@ -20,10 +20,11 @@ else:
default_encoding = locale.getpreferredencoding().lower()
def tr(s):
if default_encoding.startswith('utf') or default_encoding in ['cp936', '936', 'ms936', 'gbk']:
try:
s.encode(default_encoding)
return s
else:
return s.encode('utf-8')
except:
return str(s.encode('utf-8'))[2:-1]
def r1(pattern, text):
m = re.search(pattern, text)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册