nx_charset.nx
buildroot/runtime/nx_charset.nx
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
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
| 13 | const NX_CS_UTF8: i64 = 0 |
| 14 | const NX_CS_LATIN1: i64 = 1 |
| 15 | const NX_CS_WIN1252: i64 = 2 |
functions
| 17 | func _cs_lc(b: i64) -> i64 { if b >= 65 { if b <= 90 { return b + 32 } } return b } |
| 20 | func _cs_emit(out: *u8, pos: i64, cap: i64, cp: i64) -> i64 |
| 43 | func _cs_fill_w1252(w: *i64) -> i64 |
| 80 | func nx_charset_to_utf8(src: *u8, n: i64, cs: i64, out: *u8, cap: i64) -> i64 |
| 104 | func _cs_contains(s: *u8, n: i64, pat: *u8, pn: i64) -> i64 |
| 119 | func nx_charset_from_content_type(val: *u8, len: i64) -> i64 |
| 130 | func _cs_find(s: *u8, n: i64, pat: *u8, pn: i64) -> i64 |
| 150 | func nx_charset_sniff(buf: *u8, n: i64) -> i64 |
| 182 | func _cs_utf8_seqlen(src: *u8, i: i64, n: i64) -> i64 called by 1: nx_charset_repair_utf8 |
| 211 | func nx_charset_repair_utf8(src: *u8, n: i64, out: *u8, cap: i64) -> i64 called by 10: pr_pdf_to_reflowchkmaincs_wjsonchapter_spliter_wjson+4 calls 4: sys_mmap_cs_fill_w1252_cs_utf8_seqlen_cs_emit |