Skip to main content

Module util

Module util 

Source
Expand description

XML utility functions for character classification and string helpers.

Provides the low-level character classification routines needed by the parser, matching the XML 1.0 specification’s definitions for name characters, whitespace, and UTF-8 handling.

§Compatibility with TinyXML2

These functions match TinyXML2’s XMLUtil static methods. TinyXML2 uses a simplified character classification that covers ASCII and common Unicode ranges. Our implementation follows the same practical subset.

Functions§

collapse_whitespace
Collapses whitespace in a string according to TinyXML2’s COLLAPSE_WHITESPACE mode.
is_name_char
Returns true if the character can appear in an XML name (after the first character).
is_name_start_char
Returns true if the character can start an XML name.
is_whitespace
Returns true if the character is XML whitespace.
is_whitespace_byte
Returns true if the byte is XML whitespace.
read_name
Reads an XML name from the beginning of a string slice.
skip_whitespace
Skips whitespace characters at the beginning of a string slice.
starts_with_bom
Checks if a string starts with the UTF-8 BOM (byte order mark).
strip_bom
Strips the UTF-8 BOM from the beginning of a string if present.