code: private static final String urlEncode(String s) {
          try {
              return URLEncoder.encode(s, "UTF-8");
          } catch (Exception e) {
              logger.warn("Failed to encode '" + s + "'", e);
              return s;
          }
      }
docs: URL-encode the given string using UTF-8 encoding.