[
https://issues.apache.org/jira/browse/CSV-135?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14263480#comment-14263480
]
Rob Peime commented on CSV-135:
-------------------------------
Not a bug.
Based upon your expected/desired output, the way you are adding values to your
List<String> is incorrect.
Your expected output shows that you intended to have 3 values, each 2 chars
long: a backslash followed by a quote, a backslash followed by an n, and 2
backslashes).
But when adding values to your list, you have only added a single char for each
of the three values: a quote, a linefeed, and a forward slash.
I can confirm that escaping your input string literals give the desired output.
> Char escape doesn't work
> ------------------------
>
> 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
> 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
(v6.3.4#6332)