Skip to main content

encode_safe

Function encode_safe 

Source
pub fn encode_safe<S: ?Sized + AsRef<str>>(text: &S) -> Cow<'_, str>
Expand description

Encode &, <, >, ", ', and / as HTML entities.

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;