Skip to main content

encode_safe_to_string

Function encode_safe_to_string 

Source
pub fn encode_safe_to_string<S: AsRef<str>>(
    text: S,
    output: &mut String,
) -> &str
Expand description

Encode &, <, >, ", ', and / as HTML entities, write the result to a mutable String reference, and return the encoded string slice.

This function is not a context-independent sanitizer. Use a context-specific encoder for text, attributes, scripts, and styles.

The following characters are escaped:

  • & => &amp;
  • < => &lt;
  • > => &gt;
  • " => &quot;
  • ' => &#x27;
  • / => &#x2F;