commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CSV-135) Char escape doesn't work
Date Tue, 19 Jan 2016 18:05:39 GMT

    [ https://issues.apache.org/jira/browse/CSV-135?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15107095#comment-15107095
] 

Sebb commented on CSV-135:
--------------------------

Yes, anything goes inside double-quotes - except a double-quote (DQ).

There are two ways to support embedded DQ: doubling the DQ, or escaping the DQ.

In this case, the backslash is presumably being treated as an escape, and since the next char
is a DQ, it causes the parser to run off the end of the string.
However, if backslash is not treated as an escape, there would be no problem with the string.

AFAICT, escaping a DQ - instead of doubling it - is not a standard feature of CSV.
According to Wikipedia escaping is used in Sybase.
In which case, it suggests that the parser should default to not processing escapes in DQ
strings.

The fundamental problem here is that there is no single definition of what constitutes the
CSV format.

> 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)

Mime
View raw message