Skip to content

Instantly share code, notes, and snippets.

@jeffbryner
Created June 27, 2014 02:22
Show Gist options
  • Save jeffbryner/5647202bff7a698c3ad5 to your computer and use it in GitHub Desktop.
Save jeffbryner/5647202bff7a698c3ad5 to your computer and use it in GitHub Desktop.
to unicode or else
def to_unicode_or_bust(obj, encoding='utf-8'):
if isinstance(obj, basestring):
if not isinstance(obj, unicode):
obj = unicode(obj, encoding)
return obj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment