public static String urlEncode(final String text) {
        try {
            return URLEncoder.encode(text, StandardCharsets.UTF_8.name());
        } catch (final UnsupportedEncodingException e) {
            val message = "Unable to encode text : " + text;
            throw new TechnicalException(message, e);
        }
    }
URL encode a text using UTF-8.

@param text text to encode
@return the encoded text
pac4j-core/src/main/java/org/pac4j/core/util/CommonHelper.java