Repository navigation
v1.3.0
Added
Metadata.encodingnow reports the detected input encoding name, UTF-8 validity, and BOM presence. The plain-text, JSON, and CSV CLI formats expose the same information, while the existingMetadata::newandEncodingInfo::newsignatures remain available for compatibility. Thanks to @guitcastro for the contribution (#48, resolving #44)
Fixed
--format jsonemitted invalid JSON and--format csvemitted invalid CSV for the most common dialect there is. The detected delimiter and quote characters were interpolated into both formats with no escaping, so a comma-delimited file injected a bare,into the CSV row and a"-quoted file injected an unbalanced"into both. A comma-delimited,"-quoted file — the overwhelming majority — produced a CSV data row that a parser reads as 4 fields against a 9-field header, and JSON that fails to parse at the"quote"key. Both now escape through theescape_json/escape_csvhelpers already applied to the file path and, in verbose mode, to field namesDialect.is_utf8now reports whether the input was actually valid UTF-8. It was computed from the transcoded sample:detect_and_transcoderuns first, andencoding_rs::decodealways emits valid UTF-8 — substituting replacement characters for malformed input — so the check that followed saw valid UTF-8 no matter what was fed in. Every file, in every encoding, was reported asis_utf8: true, including through the CLI's plain, JSON and CSV output. Detection now runs on the original bytes, before transcodingDialect.is_utf8no longer misreports a valid UTF-8 file when the sample boundary happens to split a multi-byte character. Samples are cut at a raw byte offset, so an incomplete trailing sequence is now accepted while a genuinely invalid sequence anywhere in the sample is still rejected. On the defaultSampleSize::Records(100)path this affected 3 of 20 synthetic files whose cut point swept a full row period. The tolerance is confined to the sniffer's sample path: the publicdetect_encodingandis_utf8stay strict, since an incomplete sequence at a real EOF is malformed rather than truncated. The field's documentation now also states plainly that it describes the sample, as every other field inMetadatadoes — invalid bytes beyond the sampled prefix are not seen
New Contributors
- @guitcastro made their first contribution in #48
Full Changelog: v1.2.0...v1.3.0