Skip to main content

encode_safe_to_writer

Function encode_safe_to_writer 

Source
pub fn encode_safe_to_writer<S: AsRef<str>, W: Write>(
    text: S,
    output: &mut W,
) -> Result<(), Error>
Available on crate feature std only.
Expand description

Encode &, <, >, ", ', and / as HTML entities and write the result to a writer.

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;