code wiki / (root) / nx_charset.nx

nx_charset.nx

buildroot/runtime/nx_charset.nx

9035 B233 linesdepth 2pulls 2 transitivereach 15 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_charset.nx -- charset detection + transcode-to-UTF-8 for the sovereign browser. Many live pages still serve ISO-8859-1 (Latin-1) or Windows-1252; their 0x80-0xFF bytes are garbage/invalid UTF-8 unless transcoded. This organ detects the charset from a Content-Type value and transcodes a byte buffer to UTF-8 so the renderer (which then sees UTF-8) shows correct text. Windows-1252 0x80-0x9F table sourced AUTHORITATIVELY from python cp1252. Single-responsibility; nx_html_to_text / nish run this BEFORE rendering. expect_exit: 0 license_tier: ORIGINAL

dependencies 1 imports · 9 importers

nx_syscalls.nx nx_charset.nx _pdf_reflow_lib.nx nishi.nx nx_book_mojibake_gate.nx nx_chapter_split.nx nx_charset_test.nx nx_epub_book.nx nx_kf8_book.nx nx_mobi_book.nx nx_rtf_book.nx

imports: nx_syscalls.nx

imported by: _pdf_reflow_lib.nxnishi.nxnx_book_mojibake_gate.nxnx_chapter_split.nxnx_charset_test.nxnx_epub_book.nxnx_kf8_book.nxnx_mobi_book.nxnx_rtf_book.nx

structs

none

consts

13const NX_CS_UTF8: i64 = 0
14const NX_CS_LATIN1: i64 = 1
15const NX_CS_WIN1252: i64 = 2

functions

17func _cs_lc(b: i64) -> i64 { if b >= 65 { if b <= 90 { return b + 32 } } return b }
20func _cs_emit(out: *u8, pos: i64, cap: i64, cp: i64) -> i64
43func _cs_fill_w1252(w: *i64) -> i64
80func nx_charset_to_utf8(src: *u8, n: i64, cs: i64, out: *u8, cap: i64) -> i64
104func _cs_contains(s: *u8, n: i64, pat: *u8, pn: i64) -> i64
called by 1: nx_charset_from_content_type calls 1: _cs_lc
119func nx_charset_from_content_type(val: *u8, len: i64) -> i64
130func _cs_find(s: *u8, n: i64, pat: *u8, pn: i64) -> i64
called by 1: nx_charset_sniff calls 1: _cs_lc
150func nx_charset_sniff(buf: *u8, n: i64) -> i64
182func _cs_utf8_seqlen(src: *u8, i: i64, n: i64) -> i64
211func nx_charset_repair_utf8(src: *u8, n: i64, out: *u8, cap: i64) -> i64