Convert a string to unicode if it isn't already.

def unicodestr(s, encoding='utf-8', fallback='iso-8859-1'):
    """Convert a string to unicode if it isn't already."""

    if isinstance(s, unicode):
        return s

    try:
        return s.decode(encoding)
    except UnicodeError:
        return s.decode(fallback)