about summary refs log tree commit diff
path: root/format/fastxml/chars.ha
diff options
context:
space:
mode:
authorAlexey Yerin <yyp@disroot.org>2023-10-04 21:02:27 +0300
committerAlexey Yerin <yyp@disroot.org>2023-10-04 21:02:27 +0300
commitc98da05caa1c30f42bd5a3615d9cb63b4d590e9f (patch)
treed019e8c1efd4c63ca38700cf16f59f1f8db05407 /format/fastxml/chars.ha
parentc137ce659bd2449c430c0a5ac7f932f2286c250c (diff)
Vendor hare-fastxml
Diffstat (limited to 'format/fastxml/chars.ha')
-rw-r--r--format/fastxml/chars.ha32
1 files changed, 32 insertions, 0 deletions
diff --git a/format/fastxml/chars.ha b/format/fastxml/chars.ha
new file mode 100644
index 0000000..2a2cc90
--- /dev/null
+++ b/format/fastxml/chars.ha
@@ -0,0 +1,32 @@
+// License: MPL-2.0
+// (c) 2021 Drew DeVault <sir@cmpwn.com>
+use ascii;
+
+fn isnamestart(rn: rune) bool = {
+	if (rn == ':' || rn == '_' || ascii::isalpha(rn)) return true;
+	let rn = rn: u32;
+	return
+		(rn >= 0xC0 && rn <= 0xD6) ||
+		(rn >= 0xD8 && rn <= 0xF6) ||
+		(rn >= 0xF8 && rn <= 0x2FF) ||
+		(rn >= 0x370 && rn <= 0x37D) ||
+		(rn >= 0x37F && rn <= 0x1FFF) ||
+		(rn >= 0x200C && rn <= 0x200D) ||
+		(rn >= 0x2070 && rn <= 0x218F) ||
+		(rn >= 0x2C00 && rn <= 0x2FEF) ||
+		(rn >= 0x3001 && rn <= 0xD7FF) ||
+		(rn >= 0xF900 && rn <= 0xFDCF) ||
+		(rn >= 0xFDF0 && rn <= 0xFFFD) ||
+		(rn >= 0x10000 && rn <= 0xEFFFF);
+};
+
+fn isname(rn: rune) bool = {
+	if (isnamestart(rn) || rn == '-' || rn == '.' || ascii::isdigit(rn)) {
+		return true;
+	};
+	let rn = rn: u32;
+	return
+		(rn == 0xB7) ||
+		(rn >= 0x300 && rn <= 0x36F) ||
+		(rn >= 0x203F && rn <= 0x2040);
+};