Skip to content

Instantly share code, notes, and snippets.

@koorukuroo
Created April 3, 2015 10:12
Show Gist options
  • Select an option

  • Save koorukuroo/3308f88fc0ee626daa0f to your computer and use it in GitHub Desktop.

Select an option

Save koorukuroo/3308f88fc0ee626daa0f to your computer and use it in GitHub Desktop.
def to_unicode_or_bust(obj, encoding='utf-8'):
# http://farmdev.com/talks/unicode/
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