Skip to main content

unescape_bytes

Function unescape_bytes 

Source
pub fn unescape_bytes(bytes: &[u8]) -> Cow<'_, [u8]>
Expand description

Expand the five XML predefined entity references (&amp;, &lt;, &gt;, &quot;, &apos;) and numeric character references (&#NN;, &#xNN;) inside s. Intended for callers using ParseOptions::skip_entity_expansion who want to decode a specific text payload on demand.

Returns Cow::Borrowed(s) when s contains no & — i.e. the no-entity case is zero-copy.

General entities declared in a DTD (<!ENTITY foo "...">) are not expanded here; the helper has no access to the document’s entity table. If you need DTD-defined entity expansion, don’t enable skip_entity_expansion in the first place. Byte-output sibling of reader::unescape. Expands the five XML predefined entity references and numeric character references inside bytes (which must be valid UTF-8), returning the decoded form. Returns Cow::Borrowed(bytes) when no & appears.

Intended for callers using ParseOptions::skip_entity_expansion with XmlBytesReader who want to decode a specific text payload on demand. General entities declared in a DTD are not expanded — the helper has no access to the document’s entity table.