Uploaded image for project: 'Commons CSV'
  1. Commons CSV
  2. CSV-135

Char escape doesn't work properly with quoting

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: Patch Needed
    • Component/s: Printer
    • Labels:
      None

      Description

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

      produces

      """","
      ","\"
      

      instead of

      "\"","\n","\\"
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              Matzz Mateusz Zakarczemny
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: