sniff_delimiter read the first 64 KiB of the text. A first field of
three-byte characters longer than about 21,800 characters filled that
sample before its delimiter, so a semicolon or tab file opened as
comma-separated. The sample is now the first 65,536 characters, the
amount detection read before it moved into craft-csv.
The new test fails without the change: a first field of 65,535
three-byte characters followed by a semicolon is detected as comma.
sniff_delimiter skipped every record without a non-whitespace character
other than the delimiter, so a record such as ";" or ";;;" was blank to
the semicolon candidate. A semicolon export of a sheet whose only value
is far down (B40001) starts with 40,000 ";" rows, which fill the 64 KiB
sample, and the file was read as comma-separated with one column.
Records that hold only a candidate's delimiters and whitespace are now
kept apart, at most 20 per candidate. When no candidate separates the
records with other text, the same rules pick among the candidates whose
sample holds only such records. Every result that did not fall back to
comma stays the same: a row of tabs alone is still blank to the other
candidates and does not outweigh them, as #1209 set out.
sniff_delimiter reads the first 64 KiB of the text and leaves out a
record cut off at that point (#1209). When the first record is longer
than the sample, no record is counted and the function returns comma,
so a semicolon or tab file with a very wide first row opens as one
column.
When no candidate delimiter finds coherent complete records with a
delimiter in each, a candidate that finds no complete record now
counts the delimiters read so far in the first record. Delimiters
inside quoted fields are not counted. A quote inside a field that does
not start with one makes that record incoherent, and the coherent
candidate is picked. When one of those candidates ends the sample
inside a quoted field, each of them counts only up to that field's
opening quote. The per-candidate loop moved into a scan_delimiter
helper, which runs a second scan over the text before that quote.
Moved from GridCraft at 5cf52c5f: the encoding detection, delimiter
sniffing, record parser and field quoting of crates/xlsx/src/csv.rs,
and the SYLK reader of crates/engine/src/io/sylk.rs.
Fields stay text and the SYLK reader returns its own Sheet; typed
values, dates and the workbook stay in GridCraft.