Encode or decode ``url`` by applying ``func`` to all of its
    URL-encodable parts.
549876
def _urlendecode(url, func):
    
    parsed = urlparse(url)
    for attr in URL_ENCODABLE_PARTS:
        parsed = parsed._replace(**{attr: func(getattr(parsed, attr))})
    return urlunparse(parsed)
375716
def download(url):
    
    headers = {"User-Agent": USER_AGENT}
    resp = requests.get(
        url,
        timeout=REQUEST_TIMEOUT,
        headers=headers,
        allow_redirects=True,
        verify=False,
    )

    def decode(st, alt_encoding=None):
        encodings = ['ascii', 'utf-8', 'iso-8859-1', 'iso-8859-15']

        if alt_encoding:
            if isinstance(alt_encoding, basestring):
                encodings.append(alt_encoding)
            else:
                encodings.extend(alt_encoding)

        for encoding in encodings:
            try:
                return st.encode(encoding).decode("utf-8")
            except UnicodeEncodeError, UnicodeDecodeError:
                pass

        raise UnicodeError('Could not find encoding.')

    return decode(resp.text, resp.encoding)
1076355
private static String encodeUrl(String url) {
        try {
            URL u = new URL(url);
            return encodeUrl(u).toExternalForm();
        } catch (Exception e) {
            return url;
        }
	}
574312
def enurlform_app(parser, cmd, args):  # pragma: no cover
    

    parser.add_argument('values', help='the key=value pairs to URL encode', nargs='+')
    args = parser.parse_args(args)
    return enurlform(dict(v.split('=', 1) for v in args.values))
459524
function(url, body, func) {
  if (typeof url !== 'object') {
    url = parse(url);
  }

  if (!func) {
    func = body;
    body = undefined;
  }

  var opt = {
    host: url.hostname,
    port: url.port || 80,
    path: url.pathname
    //agent: false
  };

  if (body) {
    opt.headers = {
      'Content-Type': 'application/xml; charset=utf-8',
      'Content-Length': Buffer.byteLength(body),
      'Range': 'bytes=0-5120'
    };
    opt.method = 'POST';
  } else {
    opt.method = 'GET';
  }

  var req = http.request(opt);
  req.on('response', function(res) {
    var decoder = new StringDecoder('utf8')
      , total = 0
      , body = ''
      , done = false;

    var end = function() {
      if (done) return;
      done = true;
      res.body = body;
      func(null, res);
    };

    res.on('data', function(data) {
      total += data.length;
      body += decoder.write(data);
      if (total > 5120) {
        res.destroy();
        end();
      }
    }).on('error', function(err) {
      res.destroy();
      func(err);
    });

    res.on('end', end);

    // an agent socket's `end` sometimes
    // wont be emitted on the response
    res.socket.on('end', end);
  });
  req.end(body);
}
1069538
def _DecodeURL(self, url):
    
    if not url:
      return ''

    decoded_url = urlparse.unquote(url)
    if isinstance(decoded_url, py2to3.BYTES_TYPE):
      try:
        decoded_url = decoded_url.decode('utf-8')
      except UnicodeDecodeError as exception:
        decoded_url = decoded_url.decode('utf-8', errors='replace')
        logger.warning(
            'Unable to decode URL: {0:s} with error: {1!s}'.format(
                url, exception))

    return decoded_url
162139
def encode(cls, d):
        
        warnings.warn(
            'The `encode` class method of APIRequestor is deprecated and '
            'will be removed in version 2.0.'
            'If you need public access to this function, please email us '
            'at support@stripe.com.',
            DeprecationWarning)
        return urllib.urlencode(list(_api_encode(d)))
330180
public static String encode(String url, Charset charset) {
		if (StrUtil.isEmpty(url)) {
			return url;
		}
		if (null == charset) {
			charset = CharsetUtil.defaultCharset();
		}
		return URLEncoder.DEFAULT.encode(url, charset);
	}
1126220
function mergeUrlWithParams(url, params) {
        params = params || {};
        return _.isEmpty(params) ? url : url + "?" + qs.stringify(params);
    }
1281933
def uridecode(uristring, encoding='utf-8', errors='strict'):
    """"""
    if not isinstance(uristring, bytes):
        uristring = uristring.encode(encoding or 'ascii', errors)
    parts = uristring.split(b'%')
    result = [parts[0]]
    append = result.append
    decode = _decoded.get
    for s in parts[1:]:
        append(decode(s[:2], b'%' + s[:2]))
        append(s[2:])
    if encoding is not None:
        return b''.join(result).decode(encoding, errors)
    else:
        return b''.join(result)
480959
function parseUrl(url, params) {
  var paramsStr = '';

  if (typeof params === 'string') {
    paramsStr = params;
  } else if ((typeof params === 'undefined' ? 'undefined' : _typeof(params)) === 'object') {
    Object.keys(params).forEach(function (key) {
      if (url.indexOf(key + '=') < 0) {
        paramsStr += '&' + key + '=' + encodeURIComponent(params[key]);
      }
    });
  }
  // add a timestampe to remove cache
  paramsStr += '&_time=' + getNow();

  if (paramsStr[0] === '&') {
    paramsStr = paramsStr.substr(1);
  }

  return url + (url.indexOf('?') === -1 ? '?' : '&') + paramsStr;
}
1203010
def set_url_part(url, **kwargs):
    """"""
    d = parse_url_to_dict(url)

    d.update(kwargs)

    return unparse_url_dict(d)
869738
function urlEncode(data) {
  log("==================================================");
  log("Data before urlEncode");
  log("==================================================");
  log(data);

  if (data === "") {
    return data;
  }

  let find = ["~", "%20", "'"];
  let replace = ["%7E", "+", "%27"];
  let encodedData = encodeURIComponent(data);

  find.forEach((encodedChar, index) => {
    let regex = new RegExp(encodedChar, "g");
    encodedData = encodedData.replace(regex, replace[index]);
  });

  log("==================================================");
  log("Data after urlEncode");
  log("==================================================");
  log(encodedData);

  return encodedData;
}
1276417
def chunk(url):
    
    chunks = lambda l, n: [l[x: x+n] for x in xrange(0, len(l), n)]
    url_64 = base64.urlsafe_b64encode(url)
    return chunks(url_64, 255)
177594
def _encode_params(**kw):
    '''
    
    '''
    def _encode(L, k, v):
        if isinstance(v, unicode):
            L.append('%s=%s' % (k, urllib.quote(v.encode('utf-8'))))
        elif isinstance(v, str):
            L.append('%s=%s' % (k, urllib.quote(v)))
        elif isinstance(v, collections.Iterable):
            for x in v:
                _encode(L, k, x)
        else:
            L.append('%s=%s' % (k, urllib.quote(str(v))))
    args = []
    for k, v in kw.iteritems():
        _encode(args, k, v)
    return '&'.join(args)
1341337
def _encode_decode_decorator(func):
    """"""
    def wrapper(*args):
        """error catching"""
        try:
            processed_geom = func(*args)
            return processed_geom
        except ImportError as err:
            raise ImportError('The Python package `shapely` needs to be '
                              'installed to encode or decode geometries. '
                              '({})'.format(err))
    return wrapper
987841
def encode_http_params(**kw):
    '''
    
    '''
    try:
        _fo = lambda k, v: '{name}={value}'.format(
            name=k, value=to_basestring(quote(v)))
    except:
        _fo = lambda k, v: '%s=%s' % (k, to_basestring(quote(v)))

    _en = utf8

    return '&'.join([_fo(k, _en(v)) for k, v in kw.items() if not is_empty(v)])