Exemple #1
0
def _to_unicode(varchar_value):
    if varchar_value is None:
        return None
    elif isinstance(varchar_value, unicode):
        return varchar_value
    else:
        return unicode(varchar_value)
def _to_unicode(result_set, index):
    val = result_set.getString(index)
    was_null = result_set.wasNull()
    if was_null:
        return None
    elif isinstance(val, unicode):
        return val
    else:
        return unicode(val)
Exemple #3
0
def ensure_unicode(obj, encoding="utf-8", errors="strict"):
    # type: (Any, unicode, unicode) -> unicode
    """Make sure an object is converted to a proper Unicode representation."""
    if isinstance(obj, unicode):
        uobj = obj
    elif isinstance(obj, bytes):
        uobj = obj.decode(encoding, errors)
    else:
        uobj = unicode(obj)
    return uobj
Exemple #4
0
def get_past_unicode():
    from past.types import unicode

    return unicode(u"привет")
def _to_array_str(result_set, index):
    val = result_set.getArray(index)
    was_null = result_set.wasNull()
    if was_null:
        return None
    return unicode(val.toString())