编码字符为 application/x-www-form-urlencoded<br>
将需要转换的内容（ASCII码形式之外的内容），用十六进制表示法转换出来，并在之前加上%开头。<br>
此方法用于URL自动编码，类似于浏览器中键入地址自动编码，对于像类似于“/”的字符不再编码

@param url 被编码内容
@param charset 编码
@return 编码后的字符
@since 4.4.1
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);
	}
1171147
public static String encode( String url, String encoding )
    {
        String encodedURL = null;
        try
        {
            encodedURL = URLCodec.encode( url, encoding );
        }
        catch ( java.io.UnsupportedEncodingException e )
        {
            // try utf-8 as a default encoding
            try
            {
                encodedURL = URLCodec.encode( url, DEFAULT_ENCODING );
            }
            catch ( java.io.UnsupportedEncodingException ignore )
            {
            }
        }
        return encodedURL;
    }
90747
private static String encodeHTMLEntities(String string) {
		if (string == null) {
			return null;
		}
		try {
			return URLEncoder.encode(string, Charset.defaultCharset().displayName());
		} catch (UnsupportedEncodingException exception) {
			return string;
		}
	}
1060510
public static String urlEncode(String content, Charset charset, TestContext context) {
        return new UrlEncodeFunction().execute(Arrays.asList(content, charset.displayName()), context);
    }
290935
public static String encodeParams(String paramsStr, Charset charset) {
		if (StrUtil.isBlank(paramsStr)) {
			return StrUtil.EMPTY;
		}

		String urlPart = null; // url部分，不包括问号
		String paramPart; // 参数部分
		int pathEndPos = paramsStr.indexOf('?');
		if (pathEndPos > -1) {
			// url + 参数
			urlPart = StrUtil.subPre(paramsStr, pathEndPos);
			paramPart = StrUtil.subSuf(paramsStr, pathEndPos + 1);
			if (StrUtil.isBlank(paramPart)) {
				// 无参数，返回url
				return urlPart;
			}
		} else {
			// 无URL
			paramPart = paramsStr;
		}

		paramPart = normalizeParams(paramPart, charset);
		
		return StrUtil.isBlank(urlPart) ? paramPart : urlPart + "?" + paramPart;
	}
1198690
public static String encode(String value, Charset charset) {
		try {
			return URLEncoder.encode(value, charset.name());
		}
		catch (UnsupportedEncodingException ex) {
			throw new IllegalArgumentException("Characterset is not supported.");
		}
	}
1107391
public static String urlWithForm(String url, String queryString, Charset charset, boolean isEncode) {
		if (StrUtil.isBlank(queryString)) {
			// 无额外参数
			if (StrUtil.contains(url, '?')) {
				// url中包含参数
				return isEncode ? encodeParams(url, charset) : url;
			}
			return url;
		}

		// 始终有参数
		final StrBuilder urlBuilder = StrBuilder.create(url.length() + queryString.length() + 16);
		int qmIndex = url.indexOf('?');
		if (qmIndex > 0) {
			// 原URL带参数，则对这部分参数单独编码（如果选项为进行编码）
			urlBuilder.append(isEncode ? encodeParams(url, charset) : url);
			if (false == StrUtil.endWith(url, '&')) {
				// 已经带参数的情况下追加参数
				urlBuilder.append('&');
			}
		} else {
			// 原url无参数，则不做编码
			urlBuilder.append(url);
			if (qmIndex < 0) {
				// 无 '?' 追加之
				urlBuilder.append('?');
			}
		}
		urlBuilder.append(isEncode ? encodeParams(queryString, charset) : queryString);
		return urlBuilder.toString();
	}
1365389
public static String readAsString(final URL url, final String encoding, final int bufSize) {
        try (final Reader reader = new InputStreamReader(url.openStream(), encoding)) {
            final StringBuilder sb = new StringBuilder();
            final char[] cbuf = new char[bufSize];
            int count;
            while ((count = reader.read(cbuf)) > -1) {
                sb.append(String.valueOf(cbuf, 0, count));
            }
            return sb.toString();
        } catch (final IOException ex) {
            throw new RuntimeException(ex);
        }
    }
543168
public static String encodeForms(Collection<? extends Parameter<String>> queries, Charset charset) {
        StringBuilder sb = new StringBuilder();
        try {
            for (Parameter<String> query : queries) {
                sb.append(URLEncoder.encode(query.name(), charset.name()));
                sb.append('=');
                sb.append(URLEncoder.encode(query.value(), charset.name()));
                sb.append('&');
            }
        } catch (UnsupportedEncodingException e) {
            // should not happen
            throw new RequestsException(e);
        }
        if (sb.length() > 0) {
            sb.deleteCharAt(sb.length() - 1);
        }
        return sb.toString();
    }
864494
public static String urlEncode(String str)
    {
        String ret = str;

        try 
        {
            ret = URLEncoder.encode(str, "UTF-8");
        } 
        catch (UnsupportedEncodingException e) 
        {
            logger.severe("Failed to encode value: "+str);
        }

        return ret;
    }
160954
public static Map<String, List<String>> decodeParams(String paramsStr, String charset) {
		if (StrUtil.isBlank(paramsStr)) {
			return Collections.emptyMap();
		}

		// 去掉Path部分
		int pathEndPos = paramsStr.indexOf('?');
		if (pathEndPos > -1) {
			paramsStr = StrUtil.subSuf(paramsStr, pathEndPos + 1);
		}

		final Map<String, List<String>> params = new LinkedHashMap<String, List<String>>();
		final int len = paramsStr.length();
		String name = null;
		int pos = 0; // 未处理字符开始位置
		int i; // 未处理字符结束位置
		char c; // 当前字符
		for (i = 0; i < len; i++) {
			c = paramsStr.charAt(i);
			if (c == '=') { // 键值对的分界点
				if (null == name) {
					// name可以是""
					name = paramsStr.substring(pos, i);
				}
				pos = i + 1;
			} else if (c == '&') { // 参数对的分界点
				if (null == name && pos != i) {
					// 对于像&a&这类无参数值的字符串，我们将name为a的值设为""
					addParam(params, paramsStr.substring(pos, i), StrUtil.EMPTY, charset);
				} else if (name != null) {
					addParam(params, name, paramsStr.substring(pos, i), charset);
					name = null;
				}
				pos = i + 1;
			}
		}

		// 处理结尾
		if (pos != i) {
			if (name == null) {
				addParam(params, paramsStr.substring(pos, i), StrUtil.EMPTY, charset);
			} else {
				addParam(params, name, paramsStr.substring(pos, i), charset);
			}
		} else if (name != null) {
			addParam(params, name, StrUtil.EMPTY, charset);
		}

		return params;
	}
618524
public static String urlEncode(String part) {
		try {
			return URLEncoder.encode(part, Charsets.UTF_8_NAME);
		} catch (UnsupportedEncodingException ignored) { // NOSONAR
			// this exception is only for detecting and handling invalid inputs
			return null;
		}
	}
33170
public static String encodeUrlSafe(String source, String charset) {
		return Base64Encoder.encodeUrlSafe(source, charset);
	}
1145281
public String encodeURL(String url) {
        StringBuffer urlEncoded = new StringBuffer();
        int indexOfQuestionMark = url.indexOf("?");
        if (indexOfQuestionMark > 0) {
            // Handles those cases :
            // http://forums.searchenginewatch.com/showthread.php?t=9817
            // http://forums.searchenginewatch.com/showthread.php?p=72232#post72232
            String urlBeforeQuestionMark = url.substring(0, indexOfQuestionMark);
            String urlAfterQuestionMark = url.substring(indexOfQuestionMark);
            urlEncoded = urlEncoded.append(urlBeforeQuestionMark);
            urlEncoded = urlEncoded.append(";jsessionid=");
            urlEncoded = urlEncoded.append(httpSession.getId());
            urlEncoded = urlEncoded.append(urlAfterQuestionMark);
        } else {
            // Handles those cases :
            // http://www.seroundtable.com/archives/003204.html#more
            // http://www.seroundtable.com/archives#more
            int indexOfPoundSign = url.indexOf("#");
            if (indexOfPoundSign > 0) {
                String urlBeforePoundSign = url.substring(0, indexOfPoundSign);
                String urlAfterPoundSign = url.substring(indexOfPoundSign);
                urlEncoded = urlEncoded.append(urlBeforePoundSign);
                urlEncoded = urlEncoded.append(";jsessionid=");
                urlEncoded = urlEncoded.append(httpSession.getId());
                urlEncoded = urlEncoded.append(urlAfterPoundSign);
            } else {
                // Handles the rest
                // http://www.seroundtable.com/archives/003204.html
                // http://www.seroundtable.com/archives
                urlEncoded = urlEncoded.append(url);
                urlEncoded = urlEncoded.append(";jsessionid=");
                urlEncoded = urlEncoded.append(httpSession.getId());
            }
        }

        return urlEncoded.toString();
    }
444296
public static String formatUrl(String url) {

        if (MiscUtils.findChinese(url)) {

            @SuppressWarnings("deprecation")
            String tmp = URLDecoder.decode(url);
            tmp = encodeGB(tmp);

            return tmp;
        } else {
            return url;
        }
    }
1281091
def urlencoded(body, charset='ascii', **kwargs):
    """"""
    return parse_query_string(text(body, charset=charset), False)
1301137
public static String doGet(String url, Map<String, String> params, String charset) throws IOException {
        HttpURLConnection conn = null;
        String rsp = null;

        try {
            String ctype = "application/x-www-form-urlencoded;charset=" + charset;
            String query = buildQuery(params, charset);
            conn = getConnection(buildGetUrl(url, query), METHOD_GET, ctype, null);

            rsp = getResponseAsString(conn);
        } finally {
            if (conn != null) {
                conn.disconnect();
            }
        }

        return rsp;
    }