core/encoding/entity

encoding_unicode_entity

Types

4

Error

Error :: enum u8 { None = 0, Tokenizer_Is_Nil = 1, Illegal_NUL_Character = 2, Illegal_UTF_Encoding = 3, Illegal_BOM = 4, CDATA_Not_Terminated = 5, Comment_Not_Terminated = 6, Invalid_Entity_Encoding = 7, }Source

XML_Decode_Option

XML_Decode_Option :: enum u8 { // Do not decode & entities. It decodes by default. If given, overrides `Decode_CDATA`. No_Entity_Decode = 0, // CDATA is unboxed. Unbox_CDATA = 1, // Unboxed CDATA is decoded as well. Ignored if `.Unbox_CDATA` is not given. Decode_CDATA = 2, // Comments are stripped. Comment_Strip = 3, // Normalize whitespace Normalize_Whitespace = 4, }Source

Default: CDATA and comments are passed through unchanged.

Constants

7

XML_NAME_TO_RUNE_MIN_LENGTH

XML_NAME_TO_RUNE_MIN_LENGTH :: 2Source

------ GENERATED ------ DO NOT EDIT ------ GENERATED ------ DO NOT EDIT ------ GENERATED ------ This file is generated from "https://github.com/w3c/xml-entities/blob/gh-pages/unicode.xml".

UPDATE:
		- Ensure the XML file was downloaded using "tests\core\download_assets.py", given the path to the "tests\assets" directory.
		- Run "core/unicode/tools/generate_entity_table.odin"

	Odin unicode generated tables: https://github.com/odin-lang/Odin/tree/master/core/encoding/entity

		Copyright David Carlisle 1999-2025

		Use and distribution of this code are permitted under the terms of the
		W3C Software Notice and License.
		http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231.html



		This file is a collection of information about how to map
		Unicode entities to LaTeX, and various SGML/XML entity
		sets (ISO and MathML/HTML). A Unicode character may be mapped
		to several entities.

		Originally designed by Sebastian Rahtz in conjunction with
		Barbara Beeton for the STIX project

	See also: LICENSE_table.md
`<`

Procedures

9

escape_html

escape_html :: proc(s: string, allocator: mem.Allocator = context.allocator, loc = #caller_location) -> (output: string, was_allocation: bool)Source

escape_html escapes special characters like '&' to become '&amp;'. It escapes only 5 different characters: & ' < > and "

named_xml_entity_to_rune

named_xml_entity_to_rune :: proc(name: string) -> (decoded: [2]rune, rune_count: int, ok: bool)Source

Input:

	entity_name - a string, like "copy" that describes a user-encoded Unicode entity as used in XML.

	Returns:
		"decoded"    - The decoded runes if found by name, or all zero otherwise.
		"rune_count" - The number of decoded runes
		"ok"         - true if found, false if not.

	IMPORTANT: XML processors (including browsers) treat these names as case-sensitive. So do we.

Reference search

Find anything

Documentation preferences

Settings

System theme variants

Used only while Theme is set to System.