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)
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
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())