This repository has been archived on 2024-12-18. You can view files and clone it, but cannot push or open issues or pull requests.
PyBitmessage-2024-12-18/src/unqstr.py
2024-05-31 02:52:00 +09:00

24 lines
499 B
Python

import sys
import six
def ustr(v):
if six.PY3:
if isinstance(v, str):
return v
elif isinstance(v, bytes):
return v.decode("utf-8", "replace")
else:
return str(v)
# assume six.PY2
if isinstance(v, unicode):
return v.encode("utf-8", "replace")
return str(v)
def unic(v):
if six.PY3:
return v
# assume six.PY2
if isinstance(v, unicode):
return v
return unicode(v, "utf-8", "replace")