encoding.html
fn escape #
fn escape(input string, config EscapeConfig) string
escape converts special characters in the input, specifically "<", ">", and "&" to HTML-safe sequences. If quote is set to true (which is default), quotes in HTML will also be translated. Both double and single quotes will be affected. Note: escape() supports funky accents by doing nothing about them. V's UTF-8 support through string is robust enough to deal with these cases.
fn unescape #
fn unescape(input string, config UnescapeConfig) string
unescape converts entities like "<" to "<". By default it is the converse of escape. Each entity is decoded once; decoding &#34; returns ". If all is set to true, it handles named, numeric, and hex values - for example, ''', ''', and ''' then unescape to "'". Unknown entities are preserved, including a trailing & or unterminated name.
struct EscapeConfig #
@[params]
struct EscapeConfig {
pub:
quote bool = true
}
struct UnescapeConfig #
@[params]
struct UnescapeConfig {
EscapeConfig
pub:
// all decodes named and numeric references. Numeric references to zero, surrogates,
// or values above U+10FFFF become U+FFFD.
all bool
}