commons-codec's URLCodec could be used when we add that dependency.
321311
private String createUri(String uri) {
        try {
            return FileUtil.URI_SEPARATOR_CHAR
                + FilenameUtils.getPath(uri)
                + URLEncoder.encode(FilenameUtils.getBaseName(uri), StandardCharsets.UTF_8.name())
                + config.getOutputExtension();
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("Missing UTF-8 encoding??", e); // Won't happen unless JDK is broken.
        }
    }
1243278
def addResource(self, content, uri, headers):
        
        self.cache[uri] = CachedResource(content, headers)
378733
@Override
    public T addAsWebResource(File resource, String target) throws IllegalArgumentException {
        Validate.notNull(resource, "Resource should be specified");
        Validate.notNull(target, "Target should be specified");

        return addAsWebResource(new FileAsset(resource), target);
    }
217816
private synchronized void canonicalizePath () {
        char[] in = this.url.getPath().toCharArray();
        char[] out = new char[in.length];
        int length = in.length, prefixLen = 0, state = 0;

        /*
         * The canonicalization routine
         */
        for ( int i = 0; i < length; i++ ) {
            switch ( state ) {
            case 0:
                if ( in[ i ] != '/' ) {
                    // Checked exception (e.g. MalformedURLException) would be better
                    // but this would be a nightmare API wise
                    throw new RuntimeCIFSException("Invalid smb: URL: " + this.url);
                }
                out[ prefixLen++ ] = in[ i ];
                state = 1;
                break;
            case 1:
                if ( in[ i ] == '/' ) {
                    break;
                }
                else if ( in[ i ] == '.' && ( ( i + 1 ) >= length || in[ i + 1 ] == '/' ) ) {
                    i++;
                    break;
                }
                else if ( ( i + 1 ) < length && in[ i ] == '.' && in[ i + 1 ] == '.' && ( ( i + 2 ) >= length || in[ i + 2 ] == '/' ) ) {
                    i += 2;
                    if ( prefixLen == 1 )
                        break;
                    do {
                        prefixLen--;
                    }
                    while ( prefixLen > 1 && out[ prefixLen - 1 ] != '/' );
                    break;
                }
                state = 2;
            case 2:
                if ( in[ i ] == '/' ) {
                    state = 1;
                }
                out[ prefixLen++ ] = in[ i ];
                break;
            }
        }

        this.canon = new String(out, 0, prefixLen);
        if ( prefixLen > 1 ) {
            prefixLen--;
            int firstSep = this.canon.indexOf('/', 1);
            if ( firstSep < 0 ) {
                this.share = this.canon.substring(1);
                this.unc = "\\";
            }
            else if ( firstSep == prefixLen ) {
                this.share = this.canon.substring(1, firstSep);
                this.unc = "\\";
            }
            else {
                this.share = this.canon.substring(1, firstSep);
                this.unc = this.canon.substring(firstSep, prefixLen + 1).replace('/', '\\');
            }
        }
        else {
            this.canon = "/";
            this.share = null;
            this.unc = "\\";
        }
    }
1272201
@Override
    public Http2FrameCodec build() {
        Http2FrameWriter frameWriter = this.frameWriter;
        if (frameWriter != null) {
            // This is to support our tests and will never be executed by the user as frameWriter(...)
            // is package-private.
            DefaultHttp2Connection connection = new DefaultHttp2Connection(isServer(), maxReservedStreams());
            Long maxHeaderListSize = initialSettings().maxHeaderListSize();
            Http2FrameReader frameReader = new DefaultHttp2FrameReader(maxHeaderListSize == null ?
                    new DefaultHttp2HeadersDecoder(true) :
                    new DefaultHttp2HeadersDecoder(true, maxHeaderListSize));

            if (frameLogger() != null) {
                frameWriter = new Http2OutboundFrameLogger(frameWriter, frameLogger());
                frameReader = new Http2InboundFrameLogger(frameReader, frameLogger());
            }
            Http2ConnectionEncoder encoder = new DefaultHttp2ConnectionEncoder(connection, frameWriter);
            if (encoderEnforceMaxConcurrentStreams()) {
                encoder = new StreamBufferingEncoder(encoder);
            }
            Http2ConnectionDecoder decoder = new DefaultHttp2ConnectionDecoder(connection, encoder, frameReader,
                    promisedRequestVerifier(), isAutoAckSettingsFrame());

            return build(decoder, encoder, initialSettings());
        }
        return super.build();
    }
885818
function addFragmentParam(url, param, value) {
  return url +
      (url.indexOf('#') == -1 ? '#' : '&') +
      encodeURIComponent(param) + '=' + encodeURIComponent(value);
}
777236
static String urldecode(final String s) {
		try {
			return URLDecoder.decode(s, CHARSET_NAME);
		} catch (UnsupportedEncodingException e) {
			throw new RuntimeException(e);
		}
	}
422152
def _codec_error_url_quote(e):
    
    out = _fast_url_quote(e.object[e.start : e.end])

    if PY2:
        out = out.decode("utf-8")

    return out, e.end
1359217
public static <T> Codec<T> create(Class<T> cls, boolean debug, File path) {
        // to check cache early
        String uniClsName = cls.getName();
        if (isCacheEnabled()) {
            Codec codec = CACHED.get(uniClsName);
            if (codec != null) {
                return codec;
            }
        }
        return create(cls, debug, path, null, getCodeGenerator(cls));
    }
359669
def encode_with(coder)
      super

      coder['source'] = source
      coder['dependency_digest'] = dependency_digest

      coder['required_paths'] = required_assets.map { |a|
        relativize_root_path(a.pathname).to_s
      }
      coder['dependency_paths'] = dependency_paths.map { |d|
        { 'path' => relativize_root_path(d.pathname).to_s,
          'mtime' => d.mtime.iso8601,
          'digest' => d.digest }
      }
    end
137751
@Override
    public AS_ContextSec encodeIOR(Codec codec) throws Exception {
        AS_ContextSec result = new AS_ContextSec();

        result.target_supports = 0;
        result.target_requires = 0;
        result.client_authentication_mech = Util.encodeOID(NULL_OID);
        result.target_name = Util.encodeGSSExportName(NULL_OID, "");

        return result;
    }
508564
public static String urlDecode(String content, Charset charset, TestContext context) {
        return new UrlDecodeFunction().execute(Arrays.asList(content, charset.displayName()), context);
    }
379127
public static String urlDecode(String value, String enc) {
        return urlDecode(value, enc, false);
    }
1162674
public static void patch(String url, HttpConsumer<HttpExchange> endpoint, MediaTypes... mediaTypes) {
        addResource(Methods.PATCH, url, endpoint, mediaTypes);
    }
1233099
function(ctor)
	{
		var codec = null;
		
		if (ctor != null)
		{
			var name = mxUtils.getFunctionName(ctor);
			var tmp = mxCodecRegistry.aliases[name];
			
			if (tmp != null)
			{
				name = tmp;
			}
			
			codec = mxCodecRegistry.codecs[name];
			
			// Registers a new default codec for the given constructor
			// if no codec has been previously defined.
			if (codec == null)
			{
				try
				{
					codec = new mxObjectCodec(new ctor());
					mxCodecRegistry.register(codec);
				}
				catch (e)
				{
					// ignore
				}
			}
		}
		
		return codec;
	}
161555
public static StreamDecoder createInstance (URL url)
        throws IOException
    {
        String path = url.getPath();
        int idx = path.lastIndexOf('.');
        if (idx == -1) {
            log.warning("Missing extension for URL.", "url", url);
            return null;
        }
        String extension = path.substring(idx+1);
        Class<? extends StreamDecoder> clazz = _extensions.get(extension);
        if (clazz == null) {
            log.warning("No decoder registered for extension.",
                "extension", extension, "url", url);
            return null;
        }
        StreamDecoder decoder;
        try {
            decoder = clazz.newInstance();
        } catch (Exception e) {
            log.warning("Error instantiating decoder.", "url", url, e);
            return null;
        }
        decoder.init(url.openStream());
        return decoder;
    }
426259
private static void addEcc(int[] fullstream, int[] datastream, int version, int data_cw, int blocks) {

        int ecc_cw = QR_TOTAL_CODEWORDS[version - 1] - data_cw;
        int short_data_block_length = data_cw / blocks;
        int qty_long_blocks = data_cw % blocks;
        int qty_short_blocks = blocks - qty_long_blocks;
        int ecc_block_length = ecc_cw / blocks;
        int i, j, length_this_block, posn;

        int[] data_block = new int[short_data_block_length + 2];
        int[] ecc_block = new int[ecc_block_length + 2];
        int[] interleaved_data = new int[data_cw + 2];
        int[] interleaved_ecc = new int[ecc_cw + 2];

        posn = 0;

        for (i = 0; i < blocks; i++) {
            if (i < qty_short_blocks) {
                length_this_block = short_data_block_length;
            } else {
                length_this_block = short_data_block_length + 1;
            }

            for (j = 0; j < ecc_block_length; j++) {
                ecc_block[j] = 0;
            }

            for (j = 0; j < length_this_block; j++) {
                data_block[j] = datastream[posn + j];
            }

            ReedSolomon rs = new ReedSolomon();
            rs.init_gf(0x11d);
            rs.init_code(ecc_block_length, 0);
            rs.encode(length_this_block, data_block);

            for (j = 0; j < ecc_block_length; j++) {
                ecc_block[j] = rs.getResult(j);
            }

            for (j = 0; j < short_data_block_length; j++) {
                interleaved_data[(j * blocks) + i] = data_block[j];
            }

            if (i >= qty_short_blocks) {
                interleaved_data[(short_data_block_length * blocks) + (i - qty_short_blocks)] = data_block[short_data_block_length];
            }

            for (j = 0; j < ecc_block_length; j++) {
                interleaved_ecc[(j * blocks) + i] = ecc_block[ecc_block_length - j - 1];
            }

            posn += length_this_block;
        }

        for (j = 0; j < data_cw; j++) {
            fullstream[j] = interleaved_data[j];
        }
        for (j = 0; j < ecc_cw; j++) {
            fullstream[j + data_cw] = interleaved_ecc[j];
        }
    }