import urllib

strings = [
    'code - Brasil\xc3\xa2ndia',
    'code - Brasil\x83ndia',
    'code - Brasil\xe2ndia',
    ]

for yourstring in strings:
    try:
        yourstring.decode('utf-8')
    except UnicodeDecodeError:
        yourstring = yourstring.decode('latin-1').encode('utf-8')
    print urllib.quote(yourstring), "(%s)" % yourstring