std/data/xml/escape

Standard Library documentation

XML entity escaping helpers.

Module

Name
std/data/xml/escape
Area
Standard Library
Source
modules/std/data/xml/escape.zzm

NAME

std/data/xml/escape - XML entity escaping helpers.

SYNOPSIS

  from std/data/xml/escape import
    escape_xml, unescape_xml;

  let escaped := escape_xml(
    "<tea attr=\"hot\">& 'biscuits'</tea>"
  );
  let text := unescape_xml(
    "&lt;tea&gt;&#x41;&#65;&lt;/tea&gt;"
  );

IMPLEMENTATION SUPPORT

This module is supported by all implementations of ZuzuScript.

DESCRIPTION

This module provides lightweight XML entity escaping and unescaping helpers.

EXPORTS

Functions

  • escape_xml(value)

    Parameters: value is any value. Returns: String. Escapes XML special characters &, <, >, ", and '.

  • unescape_xml(value)

    Parameters: value is any value. Returns: String. Unescapes XML named entities &lt;, &gt;, &quot;, &apos;, and &amp;.

    Also decodes numeric entities in decimal and hexadecimal forms, such as &#65; and &#x41;.

COPYRIGHT AND LICENCE

std/data/xml/escape is copyright Toby Inkster.

It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.