spring-framework / org.springframework.web.util / HtmlUtils / htmlEscape

htmlEscape

open static fun htmlEscape(input: String): String

Turn special characters into HTML character references. Handles complete character set defined in HTML 4.01 recommendation.

Escapes all special characters to their corresponding entity reference (e.g. <).

Reference: http://www.w3.org/TR/html4/sgml/entities.html

Parameters

input - the (unescaped) input string

Return
the escaped string

open static fun htmlEscape(input: String, encoding: String): String

Turn special characters into HTML character references. Handles complete character set defined in HTML 4.01 recommendation.

Escapes all special characters to their corresponding entity reference (e.g. <) at least as required by the specified encoding. In other words, if a special character does not have to be escaped for the given encoding, it may not be.

Reference: http://www.w3.org/TR/html4/sgml/entities.html

Parameters

input - the (unescaped) input string

encoding - the name of a supported java.nio.charset.Charset

Return
the escaped string

Since
4.1.2