def urlencode_utf8(params):
    """
    UTF-8 safe variant of urllib.urlencode.
    http://stackoverflow.com/a/8152242
    """
    if hasattr(params, 'items'):
        params = params.items()
    params = (
        '='.join((
            quote_plus(k.encode('utf8'), safe='/'),
            quote_plus(v.encode('utf8'), safe='/')
        )) for k, v in params
    )
    return '&'.join(params)
UTF-8 safe variant of urllib.urlencode.
    http://stackoverflow.com/a/8152242