Tokenise CSV text into rows of raw string fields. Handles quoted fields
(delimiters, newlines and "" escapes inside quotes). A trailing newline does
not produce a spurious empty final row.
A field is cut out of the text as slices between the characters that matter (a quote,
the delimiter, CR, LF) and joined once, never built one character at a time: field += ch
made a rope of one piece per character, and a 20 MB cell (a hostile or broken answer under
the size cap) took the process past a 512 MB heap and crashed it before anything was printed.
A field of many pieces (every "" escape ends one) is joined every PART_BATCH pieces through a
TextBuilder, so its memory follows its text, not its number of escapes: one piece per "", a
string and an array slot each, exhausted a small heap on a 15 MB cell, within both budgets.
More than MAX_CSV_ROWS rows or MAX_CSV_CELLS cells is a BundeswahlParseError.
Tokenise CSV text into rows of raw string fields. Handles quoted fields (delimiters, newlines and
""escapes inside quotes). A trailing newline does not produce a spurious empty final row.A field is cut out of the text as slices between the characters that matter (a quote, the delimiter, CR, LF) and joined once, never built one character at a time:
field += chmade a rope of one piece per character, and a 20 MB cell (a hostile or broken answer under the size cap) took the process past a 512 MB heap and crashed it before anything was printed. A field of many pieces (every""escape ends one) is joined every PART_BATCH pieces through a TextBuilder, so its memory follows its text, not its number of escapes: one piece per"", a string and an array slot each, exhausted a small heap on a 15 MB cell, within both budgets. More than MAX_CSV_ROWS rows or MAX_CSV_CELLS cells is a BundeswahlParseError.