Skip to main content

Module host_text

Module host_text 

Source
Expand description

Read text from the host filesystem in a Windows-friendly way.

Windows editors often save scripts as UTF-8 with BOM or UTF-16 LE with BOM (“Unicode” in Notepad). std::fs::read_to_string assumes UTF-8 only, which can yield mojibake or load failures. VFS export/sync for cargo/rustup already uses binary std::fs::read / write; this module targets text loads: -f scripts, source / . from disk, nested source in .dsh, and .todo.json.

Functions§

decode_host_text_bytes
Decode bytes from a host text file: UTF-16 LE/BE (with BOM), else UTF-8 (optional BOM).
read_host_text
Read a host file and decode as for decode_host_text_bytes.
script_text_from_vfs_bytes
Decode VFS file bytes as script/JSON text (UTF-8 with optional BOM, or UTF-16 with BOM).
strip_utf8_bom
Strip a leading UTF-8 BOM (EF BB BF) if present.