提交 2724c5d9 编写于 作者: N Nicolas Hennion 提交者: GitHub

Merge pull request #1108 from GoMapur/develop

Python encoding in python2 and python3
...@@ -85,7 +85,9 @@ if PY3: ...@@ -85,7 +85,9 @@ if PY3:
return iter(d.values()) return iter(d.values())
def u(s): def u(s):
return s if isinstance(s, text_type):
return s
return s.decode('utf-8', 'replace')
def b(s): def b(s):
if isinstance(s, binary_type): if isinstance(s, binary_type):
...@@ -143,10 +145,14 @@ else: ...@@ -143,10 +145,14 @@ else:
return d.itervalues() return d.itervalues()
def u(s): def u(s):
if isinstance(s, text_type):
return s
return s.decode('utf-8') return s.decode('utf-8')
def b(s): def b(s):
return s if isinstance(s, binary_type):
return s
return s.encode('utf-8', 'replace')
def nativestr(s): def nativestr(s):
if isinstance(s, binary_type): if isinstance(s, binary_type):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册