Skip to content

v1.3.0

Choose a tag to compare

@jqnatividad jqnatividad released this 03 Sep 11:47
· 77 commits to main since this release

Added

  • Metadata.encoding now 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 existing Metadata::new and EncodingInfo::new signatures remain available for compatibility. Thanks to @guitcastro for the contribution (#48, resolving #44)

Fixed

  • --format json emitted invalid JSON and --format csv emitted 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 the escape_json/escape_csv helpers already applied to the file path and, in verbose mode, to field names
  • Dialect.is_utf8 now reports whether the input was actually valid UTF-8. It was computed from the transcoded sample: detect_and_transcode runs first, and encoding_rs::decode always 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 as is_utf8: true, including through the CLI's plain, JSON and CSV output. Detection now runs on the original bytes, before transcoding
  • Dialect.is_utf8 no 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 default SampleSize::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 public detect_encoding and is_utf8 stay 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 in Metadata does — invalid bytes beyond the sampled prefix are not seen

New Contributors

Full Changelog: v1.2.0...v1.3.0