You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Opher Shachar (JIRA)" <ji...@apache.org> on 2019/06/16 20:53:00 UTC
[jira] [Commented] (CSV-135) Char escape doesn't work properly with
quoting
[ https://issues.apache.org/jira/browse/CSV-135?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16865157#comment-16865157 ]
Opher Shachar commented on CSV-135:
-----------------------------------
Sorry, I probably did not make my point clear before.
If the field value is:
* "D:\Property Documents\ID 1.docx"
the `\` is obviously a literal not an escape. While for
* "3rd Lincoln boulevard\, Miami\, FL"
the `\` may or may-not be an escape.
The solution could be by adding a new flag (or a new {{enum}}) that modifies {{QuoteMode}}'s handling by making it explicit whether `\` are literals, or an escape only if followed by specific chars (i.e. `,`,`\`) or always an escape.
> Char escape doesn't work properly with quoting
> ----------------------------------------------
>
> Key: CSV-135
> URL: https://issues.apache.org/jira/browse/CSV-135
> Project: Commons CSV
> Issue Type: Bug
> Components: Printer
> Affects Versions: 1.0
> Reporter: Mateusz Zakarczemny
> Priority: Major
> Fix For: Patch Needed
>
>
> Following code:
> {code}
> CSVFormat format = CSVFormat.DEFAULT
> .withRecordSeparator('\n')
> .withQuote('"')
> .withEscape('\\');
> CSVPrinter printer = new CSVPrinter(System.out, format);
> List<String> l = new LinkedList<String>();
> l.add("\"");
> l.add("\n");
> l.add("\\");
> printer.printRecord(l);
> {code}
> produces
> {code}
> """","
> ","\"
> {code}
> instead of
> {code}
> "\"","\n","\\"
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)