greenhouse/libs/ustr.py
Cerno_b c35f09747a
Pep 8 (#720)
* rename local variables in main file

* additional renaming of functions and variables

* Rename main file functions

* Rename functions and variables in canvas.py

* Rename functions and locals for remaining files

* Rename non-Qt derived class' members

* Rename members of Qt-derived classes

* Fix paint label issue
2021-03-14 16:56:14 -07:00

18 lines
534 B
Python

import sys
from libs.constants import DEFAULT_ENCODING
def ustr(x):
"""py2/py3 unicode helper"""
if sys.version_info < (3, 0, 0):
from PyQt4.QtCore import QString
if type(x) == str:
return x.decode(DEFAULT_ENCODING)
if type(x) == QString:
# https://blog.csdn.net/friendan/article/details/51088476
# https://blog.csdn.net/xxm524/article/details/74937308
return unicode(x.toUtf8(), DEFAULT_ENCODING, 'ignore')
return x
else:
return x