code wiki / (root) / nx_book_mojibake_gate.nx

nx_book_mojibake_gate.nx

buildroot/runtime/nx_book_mojibake_gate.nx

4941 B80 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind gate/prooftopic book
docsdependenciesstructsconstsfunctions

about

nx_book_mojibake_gate.nx -- liar-kill gate for the library mojibake fix (nx_charset_repair_utf8). The operator's report: book text "there's" renders as "there<>s" -- the curly apostrophe (Windows-1252 byte 0x92) survives raw into a UTF-8-served page, where a lone 0x92 is an invalid continuation byte -> U+FFFD. This gate proves the repair pass byte-for-byte: it (a) fixes the reported byte, (b) fixes the other smart-punctuation + Latin-1 bytes, and CRITICALLY (c) is IDEMPOTENT on already-valid UTF-8 (it must NOT double-encode a real ' / é -- that would be the cure-becomes-the-disease regression). Teeth: a known double-encoded length is rejected. expect_exit: 0 license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_charset.nx nx_book_mojibake_gate.nx

imports: nx_syscalls.nxnx_charset.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main mg_p sys_write sys_mmap chk sys_mmap ↻ nx_charset_repair_utf8 sys_mmap ↻ _cs_fill_w1252 _cs_utf8_seqlen _cs_emit mg_p ↻ mg_n sys_write ↻ sys_mmap ↻ nx_charset_repair_utf8 ↻ mg_n ↻ sys_exit

structs

none

consts

none

functions

11func mg_p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 2: chkmain calls 1: sys_write
12func mg_n(v0: i64) -> i64 { var v: i64=v0; if v<0 { sys_write(1,"-" as *u8,1); v=0-v } let b: *u8=sys_mmap(24); var k: i64=0; if v==0 {b[0]=48 as u8;k=1} while v>0 {b[k]=(48+(v%10)) as u8; v=v/10; k=k+1} let o: *u8=sys_mmap(24); var j: i64=0; while j<k {o[j]=b[k-1-j];j=j+1} sys_write(1,o,k); return 0 }
called by 2: chkmain calls 2: sys_writesys_mmap
15func chk(label: *u8, src: *u8, sn: i64, exp: *u8, en: i64, pf: *i64) -> i64
26func main() -> i64