Skip to content

Instantly share code, notes, and snippets.

@graingerkid
Created May 5, 2015 20:44
Show Gist options
  • Save graingerkid/f39b8ca193fff1460a75 to your computer and use it in GitHub Desktop.
Save graingerkid/f39b8ca193fff1460a75 to your computer and use it in GitHub Desktop.
Function to always return unicode
# -*- coding: utf-8 -*-
def to_unicode(unicode_or_str):
'''Function to always return unicode
'''
if isinstance(unicode_or_str, str):
value = unicode_or_str.decode('utf-8')
else:
value = unicode_or_str
return value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment