std/csv
std/csv
Section titled “std/csv”std/csv — CSV escape / join / single-line parse (RFC 4180). csv_escape(s) quotes fields containing comma / quote / newline. csv_join(arr) joins after escaping each field. csv_parse_line(s) parses ONE CSV record (no embedded newline support — multi-line records left for a richer follow-up). Migrated from the auto-injected prelude per docs/PRELUDE-TO-MODULES.md.
csv_escape
Section titled “csv_escape”pub function csv_escape(s: string): string=== CSV escape / join ===
csv_escape(s) — return a CSV field per RFC 4180. Fields
containing comma / double-quote / newline get wrapped in
”…” with interior quotes doubled. Other inputs pass
through unchanged.
csv_join(arr) — join with ”,” after escaping each field.
csv_join
Section titled “csv_join”pub function csv_join(arr: string[]): stringcsv_parse_line
Section titled “csv_parse_line”pub function csv_parse_line(s: string): string[]csv_parse_line(s) — RFC 4180 parser for a single line.
Splits on ,, but a field wrapped in "..." may contain
commas / newlines, and "" inside a quoted field decodes
to a single ". Returns the field list with quotes
stripped + escapes unescaped. Newlines in the input
terminate the line — parsing a multi-line CSV requires
pre-splitting on \n EXCEPT inside quoted fields, which
is a more complex parser left for a follow-up. For the
common single-line case (CSV header / a single record)
this helper covers the surface.