feat(inspector): choose the CSV escape character (doubled quote or backslash)#1944
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d7190600eb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| public var delimiter: UInt8 | ||
| public var quoteChar: UInt8 | ||
| public var escapeChar: UInt8 = 0x22 |
There was a problem hiding this comment.
Keep doubled escaping synchronized with the quote character
When a dialect uses a single quote as its quote character, this fixed 0x22 default makes the parser treat doubled single quotes as a close quote rather than an escape. This regresses the CSV importer: CSVImportParsing.resolveDialect changes quoteChar for its existing Single quote option but leaves this new property at 0x22, so input such as 'It''s fine',x is decoded incorrectly (and embedded delimiters/newlines after an escaped quote can also be mis-tokenized). The inspector likewise allows selecting Single Quote together with “Doubled Quote,” but that combination writes/parses using a literal double-quote escape instead of doubling the selected quote character.
Useful? React with 👍 / 👎.
a48d85a to
31a66c0
Compare
d719060 to
429a4dc
Compare
|
Addressed a code review. Findings and fixes:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 429a4dcfd9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if escape != quote, byte == escape, i + 1 < end { | ||
| field.append(bytes[i + 1]) | ||
| i += 2 | ||
| continue |
There was a problem hiding this comment.
Preserve backslashes before ordinary characters
With Backslash selected for files that use it only to escape quotes, a quoted value containing a literal backslash before an ordinary character is corrupted: for example, "C:\new" is decoded as C:new. This branch consumes the escape byte before any following byte, whereas only \" and \\ are emitted by the writer. Restrict escaping to the quote and escape characters (and make the analogous paths in field and indexRows agree) so ordinary backslashes survive imports.
Useful? React with 👍 / 👎.
31a66c0 to
1e9c6e6
Compare
429a4dc to
9282c8d
Compare
1e9c6e6 to
6a09a40
Compare
9282c8d to
3998ab8
Compare
6a09a40 to
31cdb39
Compare
3998ab8 to
d9a208c
Compare
31cdb39 to
1b2c45a
Compare
d9a208c to
3b7af82
Compare
1b2c45a to
a04770b
Compare
3b7af82 to
89d708a
Compare
89d708a to
db38fa1
Compare
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
Part 6 (final) toward #1469 (CSV structural editing). The escape character field, completing the Set CSV Properties dialog. Stacked on #1943 (base branch
feat/1469-csv-properties).What
\"now read and save correctly.Why
csvmenu.cppin Tablecruncher and DataGrip's format dialog both let you pick the escape mechanism, because real exports (notably MySQL) use backslash escaping instead of RFC 4180 quote doubling. This was the one property from #1469's dialog not yet wired.How
CSVDialectgains anescapeCharfield, defaulting to the quote byte (so the default is unchanged RFC 4180 behavior). It is a new stored property with a default; the existing public initializer is untouched, so this is additive to PluginKit (no version bump).CSVStreamingParser(indexRows, parseRow, field) honors the escape byte inside a quoted field only when it differs from the quote byte; when they are equal the existing doubled-quote path runs unchanged, so every existing file parses exactly as before.CSVWriterescapes an embedded quote (and the escape byte itself) with the escape character in backslash mode, and keeps doubling quotes in the default mode.CSVPropertyOptionsmapping into the reload dialect.Tests
\"to a quote and\\to a backslash; the doubled-quote default is unchanged.CSVDialect.escapeChardefaults to the quote byte;CSVPropertyOptionsmaps the escape choice into the dialect.Docs / changelog
docs/features/csv-inspector.mdxnotes the escape-character choice.[Unreleased].Needs a local Xcode build to confirm compilation. PluginKit changes (a new
CSVDialectfield and parser method-body changes) are additive; no version bump.