diff --git a/src/main/java/org/apache/commons/csv/CSVPrinter.java b/src/main/java/org/apache/commons/csv/CSVPrinter.java index 6a71ec60..e8a9c815 100644 --- a/src/main/java/org/apache/commons/csv/CSVPrinter.java +++ b/src/main/java/org/apache/commons/csv/CSVPrinter.java @@ -242,7 +242,9 @@ public class CSVPrinter implements Flushable, Closeable { quote = !(object instanceof Number); break; case NONE: - throw new IllegalArgumentException("Not implemented yet"); + // Use the existing escaping code + printAndEscape(value, offset, len); + return; case MINIMAL: if (len <= 0) { // always quote an empty token that is the first diff --git a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java index 362b488b..c9b465d4 100644 --- a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java +++ b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java @@ -381,6 +381,17 @@ public class CSVPrinterTest { printer.close(); } + @Test + public void testDelimeterQuoteNONE() throws IOException { + final StringWriter sw = new StringWriter(); + final CSVFormat format = CSVFormat.newBuilder().withEscape('!').withQuotePolicy(Quote.NONE).build(); + final CSVPrinter printer = new CSVPrinter(sw, format); + printer.print("a,b,c"); + printer.print("xyz"); + assertEquals("a!,b!,c,xyz", sw.toString()); + printer.close(); + } + @Test public void testEOLQuoted() throws IOException { final StringWriter sw = new StringWriter();