spring-framework / org.springframework.web.util / UriUtils / encode

encode

open static fun encode(source: String, encoding: String): String

Encode characters outside the unreserved character set as defined in RFC 3986 Section 2.

This can be used to ensure the given String will not contain any characters with reserved URI meaning regardless of URI component.

Parameters

source - the String to be encoded

encoding - the character encoding to encode to

Exceptions

UnsupportedEncodingException - when the given encoding parameter is not supported

Return
the encoded String

open static fun encode(source: String, charset: Charset): String

Encode characters outside the unreserved character set as defined in RFC 3986 Section 2.

This can be used to ensure the given String will not contain any characters with reserved URI meaning regardless of URI component.

Parameters

source - the String to be encoded

charset - the character encoding to encode to

Return
the encoded String

Since
5.0