VirtualBox

Changeset 82635 in vbox


Ignore:
Timestamp:
Dec 22, 2019 6:53:40 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
135522
Message:

common/utils.py: Added toUnicode method.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/common/utils.py

    r81112 r82635  
    6363    xrange = range; # pylint: disable=redefined-builtin,invalid-name
    6464    long = int;     # pylint: disable=redefined-builtin,invalid-name
     65
     66
     67#
     68# Strings.
     69#
     70
     71def toUnicode(sString, encoding = None, errors = 'strict'):
     72    """
     73    A little like the python 2 unicode() function.
     74    """
     75    if sys.version_info[0] >= 3:
     76        if isinstance(sString, bytes):
     77            return str(sString, encoding if encoding else 'utf-8', errors);
     78    else:
     79        if not isinstance(sString, unicode):
     80            return unicode(sString, encoding, errors);
     81    return sString;
     82
    6583
    6684
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette