Expand description
The delimited-file DIALECT layer – what makes kobold-csv CSV-aware.
A Dialect fixes the four parameters that decide how a flat record of string fields becomes one line
of delimited text and back: the field delimiter (, | \t …), the quote character, whether to
quote quote_all fields unconditionally, and the LineTerminator used between rows.
§Quoting (RFC-4180 style)
A field is QUOTED when it contains the delimiter, the quote character, a carriage return, or a line feed
(or always, when quote_all). Inside a quoted field an embedded quote is DOUBLED (" -> ""). This is
the de-facto CSV escaping convention (RFC 4180, and what spreadsheets/COPY ... CSV agree on). Doing it
by hand – rather than depending on a CSV crate – keeps kobold-csv std-only and lets the escaping itself
be evidence (KOBOLD.CSV.ESCAPE): the writer and the fail-closed reader are exact inverses.
§Fail-closed reader
parse_row is deliberately strict: a quote that opens a field but never closes, or stray text after a
closing quote, is a Finding, NEVER a best-effort guess. A reconciliation tool must be able to trust
that a row either parsed exactly or was rejected with a reason – silent recovery would corrupt custody.
This module is independent of GnuCOBOL/libcob.
Structs§
- Dialect
- A delimited-file dialect: delimiter, quote char, quote-all flag, and line terminator.
Enums§
- Line
Terminator - The line terminator a dialect writes between rows (and tolerates when reading).
Functions§
- parse_
row KOBOLD.CSV.ESCAPE/ parse evidence: FAIL-CLOSED parse of onelineof delimited bytes into its fields under dialectd.- write_
field - Write one
fieldtooutunder dialectd, quoting and doubling embedded quotes as required. The inverse ofparse_row’s field handling:write_field/parse_roware an exact round-trip pair. - write_
row - Write a full
rowof fields tooutunder dialectd, joining with the delimiter and appending the line terminator. Does NOT add a trailing terminator beyond this row’s own.