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

Char escape doesn't work properly with quoting

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.0
    • Patch Needed
    • Printer
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: