- character which will be encoded by URL encoding
503847
public static String encodeToSafeAsciiFileNameString(String str, Charset strCharset) {
        if (str == null) {
            return str;
        }
        if (!SAFE_ASCII_PATTERN.matcher(str).matches()) {
            return calcSHA1Digest(str, strCharset);
        }
        // encode again since if str is SHA1 digest
        // it can easily conflict with the other encoded string
        if (SHA1_DIGEST_PATTERN.matcher(str).matches()) {
            return calcSHA1Digest(str, strCharset);
        }
        return str;
    }
162933
public static String urlEncode(String str) {
        try {
            String encodeForForm = URLEncoder.encode(str, "UTF-8");
            String encodeForUrl = encodeForForm.replace("+", "%20");
            return encodeForUrl;
        } catch (UnsupportedEncodingException e) {
            throw new IllegalStateException("JVM does not support UTF-8");
        }
    }
739895
function(str) {
  // Check for empty string
  if (str === '') {
    return '!';
  }
  // 1. URL encode
  // 2. URL encode all exclamation marks (replace ! with %21)
  // 3. URL encode all tilde (replace ~ with %7e)
  //    This ensures that when using ~ as separator in CompositeKey we can
  //    do prefix matching
  // 4. Replace % with exclamation marks for Azure compatibility
  return encodeURIComponent(str)
    .replace(/!/g, '%21')
    .replace(/~/g, '%7e')
    .replace(/%/g, '!');
}
72329
def urlencode_unicode(data, doseq=0):
    """"""
    data_iter = None
    if isdict(data):
        data_iter = list(data.items())
    elif islist(data):
        data_iter = data

    if data_iter:
        for i, (key, value) in enumerate(data_iter):
            if isinstance(value, text_type):
                # try to convert to str
                try:
                    safe_val = str(value)
                except UnicodeEncodeError:
                    # try to encode as utf-8
                    # if an exception is raised here then idk what to do
                    safe_val = value.encode('utf-8')
                finally:
                    if isdict(data):
                        data[key] = safe_val
                    else:
                        data[i] = (key, safe_val)

    return urlencode(data, doseq=doseq)
118683
function encode(s) {
            if (!/[^\w-.]/.test(s)) {
                // if the string is only made up of alpha-numeric, underscore,
                // dash or period, we can use it directly.
                return s;
            }

            // we need to escape other characters
            s = s.replace(/[^\w-.]/g, function(ch) {
                if (ch === "$") {
                    return "!";
                }

                // use the character code for this one
                ch = ch.charCodeAt(0);

                if (ch < 0x100) {
                    // if less than 256, use "*[2-char code]"
                    return "*" + ("00" + ch.toString(16)).slice(-2);
                } else {
                    // use "**[4-char code]"
                    return "**" + ("0000" + ch.toString(16)).slice(-4);
                }
            });

            return s;
        }
1097457
def urlencode(self):
        
        output = ('%s=%s' % (k, quote(v)) for k, v in self.items())
        return '&'.join(output)
934595
function encodeSpecialChars(str, specialCharsReg) {
        // encodeURI( ) is intended to encode complete URIs,
        // the following ASCII punctuation characters,
        // which have special meaning in URIs, are not escaped either:
        // ; / ? : @ & = + $ , #
        return encodeURI(str).replace(specialCharsReg, function (m) {
            return '%' + padding2(m.charCodeAt(0).toString(16));
        });
    }
412741
def urlencode_utf8(params):
    
    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)
1055616
def url_quote(string, charset='utf-8', errors='strict', safe='/:'):
    
    if not isinstance(string, (text_type, bytes, bytearray)):
        string = text_type(string)
    if isinstance(string, text_type):
        string = string.encode(charset, errors)
    if isinstance(safe, text_type):
        safe = safe.encode(charset, errors)
    safe = frozenset(bytearray(safe) + _always_safe)
    rv = bytearray()
    for char in bytearray(string):
        if char in safe:
            rv.append(char)
        else:
            rv.extend(('%%%02X' % char).encode('ascii'))
    return to_native(bytes(rv))
1076355
private static String encodeUrl(String url) {
        try {
            URL u = new URL(url);
            return encodeUrl(u).toExternalForm();
        } catch (Exception e) {
            return url;
        }
	}
777236
static String urldecode(final String s) {
		try {
			return URLDecoder.decode(s, CHARSET_NAME);
		} catch (UnsupportedEncodingException e) {
			throw new RuntimeException(e);
		}
	}
461788
private static String decodeHTMLEntities(String string) {
		if (string == null) {
			return null;
		}
		try {
			return URLDecoder.decode(string, Charset.defaultCharset().displayName());
		} catch (UnsupportedEncodingException exception) {
			return string;
		}
	}
94982
def uriencode(uristring, safe='', encoding='utf-8', errors='strict'):
    """"""
    if not isinstance(uristring, bytes):
        uristring = uristring.encode(encoding, errors)
    if not isinstance(safe, bytes):
        safe = safe.encode('ascii')
    try:
        encoded = _encoded[safe]
    except KeyError:
        encoded = _encoded[b''][:]
        for i in _tointseq(safe):
            encoded[i] = _fromint(i)
        _encoded[safe] = encoded
    return b''.join(map(encoded.__getitem__, _tointseq(uristring)))
531169
private String encode(String str) {
        if (str == null) {
            return null;
        }
        try {
            return URLEncoder.encode(str, Charsets.UTF_8.name());
        } catch (UnsupportedEncodingException e) {
            // Should never happen
            throw Throwables.propagate(e);
        }
    }
1307446
public static String encode(String url, String charset) throws UtilException {
		if (StrUtil.isEmpty(url)) {
			return url;
		}
		return encode(url, StrUtil.isBlank(charset) ? CharsetUtil.defaultCharset() : CharsetUtil.charset(charset));
	}
1311399
private static String decodeUrl(String url) {
        if (url == null) {
            return null;
        }

        try {
            return URLDecoder.decode(url, CHARSET_UTF8);
        } catch (UnsupportedEncodingException e) {
            return url;
        }
    }
153468
static String urlencode(final String s) {
		try {
			return URLEncoder.encode(s, CHARSET_NAME);
		} catch (UnsupportedEncodingException e) {
			throw new RuntimeException(e);
		}
	}