xml::escape

Function escape_str_pcdata

Source
pub fn escape_str_pcdata(s: &str) -> Cow<'_, str>
Expand description

Performs escaping of common XML characters inside PCDATA.

This function replaces several important markup characters with their entity equivalents:

  • <&lt;
  • &&amp;

The resulting string is safe to use inside PCDATA sections but NOT inside attribute values.

Does not perform allocations if the given string does not contain escapable characters.