Fix unicode conversion in Python3
This commit is contained in:
parent
8b29900be4
commit
ed48185732
1 changed files with 5 additions and 2 deletions
|
@ -8,7 +8,10 @@ def unicode(text):
|
||||||
text = text.decode('utf-8')
|
text = text.decode('utf-8')
|
||||||
import __builtin__
|
import __builtin__
|
||||||
return __builtin__.unicode(text)
|
return __builtin__.unicode(text)
|
||||||
return str(text)
|
elif not isinstance(text, str):
|
||||||
|
return text.decode('utf-8')
|
||||||
|
else:
|
||||||
|
return text
|
||||||
|
|
||||||
|
|
||||||
def bytes(text):
|
def bytes(text):
|
||||||
|
@ -148,4 +151,4 @@ def setdefaultencoding(encoding):
|
||||||
if func is None:
|
if func is None:
|
||||||
raise RuntimeError("Could not find setdefaultencoding")
|
raise RuntimeError("Could not find setdefaultencoding")
|
||||||
sys.setdefaultencoding = func
|
sys.setdefaultencoding = func
|
||||||
return func(encoding)
|
return func(encoding)
|
||||||
|
|
Loading…
Reference in a new issue