public static String encode(String url, String encode)
            throws UnsupportedEncodingException {
        StringBuilder sb = new StringBuilder();
        StringBuilder noAsciiPart = new StringBuilder();
        for (int i = 0; i < url.length(); i++) {
            char c = url.charAt(i);
            if (c > 255) {
                noAsciiPart.append(c);
            } else {
                if (noAsciiPart.length() != 0) {
                    sb.append(URLEncoder.encode(noAsciiPart.toString(), encode));
                    noAsciiPart.delete(0, noAsciiPart.length());
                }
                sb.append(c);
            }
        }
        return sb.toString();
    }

 

相关文章:

  • 2022-12-23
  • 2021-11-17
  • 2021-07-09
  • 2021-09-15
  • 2022-01-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-12
  • 2021-12-13
  • 1970-01-01
  • 2021-12-14
  • 2022-12-23
相关资源
相似解决方案