interplane.Get Omega
Read in your language

interplane-forge

INTERPLANE Forge

Brought by drakestapleton

branch main Branches Tags History

interplane-forge / patch / p2utf8.om

79 lines · 1534 bytes Raw Blame History
1note patch/p2utf8.om: the text rules of a title and a description (docs/collab-write.md section 2),
2note over the decoded field gpfv. The same code as collab/co9comp.om cowutf8, coctlok and coulen under
3note this slice's names: the store-reading build composes collab out (server/nocollab.om), so the
4note patch intake carries its own copy and needs no collab unit.
5note pawutf8 n ml: well-formed UTF-8 (no overlong forms, surrogates or code points over U+10FFFF), no
6note NUL, C0 control or DEL byte except tab and LF when ml
7fn pawutf8 n ulong ml bool to bool
8i = ulong 0
9while lt i n bound 70000
10c = get gpfv i
11if lt c 128
12if eq pactlok c ml false
13ret false
14end
15i = add i 1
16else
17k = paulen i n
18if eq k 0
19ret false
20end
21i = add i k
22end
23end
24ret true
25end
26fn pactlok c uchar ml bool to bool
27if eq c 127
28ret false
29end
30if ge c 32
31ret true
32end
33if and ml or eq c 9 eq c 10
34ret true
35end
36ret false
37end
38note paulen i n: byte length of the multi-byte sequence at gpfv[i], 0 when it is malformed
39fn paulen i ulong n ulong to ulong
40c = get gpfv i
41k = ulong 0
42lo = uchar 128
43hi = uchar 191
44if and ge c 194 le c 223
45k = ulong 2
46end
47if and ge c 224 le c 239
48k = ulong 3
49if eq c 224
50lo = uchar 160
51end
52if eq c 237
53hi = uchar 159
54end
55end
56if and ge c 240 le c 244
57k = ulong 4
58if eq c 240
59lo = uchar 144
60end
61if eq c 244
62hi = uchar 143
63end
64end
65if or eq k 0 gt add i k n
66ret ulong 0
67end
68d = get gpfv add i 1
69if or lt d lo gt d hi
70ret ulong 0
71end
72for j ulong sub k 2 bound 2
73d = get gpfv add add i 2 j
74if or lt d 128 gt d 191
75ret ulong 0
76end
77end
78ret k
79end