This repository has been archived on 2024-08-21. You can view files and clone it, but cannot push or open issues or pull requests.
PyBitmessage-2024-08-21/src/unqstr.py

22 lines
416 B
Python
Raw Normal View History

2024-05-23 06:28:40 +02:00
import sys
2024-05-26 03:18:08 +02:00
import six
2024-05-23 06:28:40 +02:00
def ustr(v):
2024-05-26 03:18:08 +02:00
if six.PY3:
2024-05-23 06:28:40 +02:00
if isinstance(v, str):
return v
else:
return str(v)
2024-05-26 03:18:08 +02:00
# assume six.PY2
2024-05-23 06:28:40 +02:00
if isinstance(v, unicode):
return v.encode("utf-8", "replace")
return str(v)
def unic(v):
2024-05-26 03:18:08 +02:00
if six.PY3:
2024-05-23 06:28:40 +02:00
return v
2024-05-26 03:18:08 +02:00
# assume six.PY2
2024-05-23 06:28:40 +02:00
if isinstance(v, unicode):
return v
return unicode(v, "utf-8", "replace")