Skip to content

Commit 1746b74

Browse files
committed
Document why we use CRLF rather than local line separator
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1300706 13f79535-47bb-0310-9956-ffa450edef68
1 parent 0ea3603 commit 1746b74

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/main/java/org/apache/commons/csv/CSVFormat.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
*/
3030
public class CSVFormat implements Serializable {
3131

32+
/** According to RFC 4180, line breaks are delimited by CRLF */
33+
private static final String CRLF = "\r\n";
3234
private final char delimiter;
3335
private final char encapsulator;
3436
private final char commentStart;
@@ -49,7 +51,7 @@ public class CSVFormat implements Serializable {
4951
static final char DISABLED = '\ufffe';
5052

5153
/** Standard comma separated format as defined by <a href="http://tools.ietf.org/html/rfc4180">RFC 4180</a>. */
52-
public static final CSVFormat DEFAULT = new CSVFormat(',', '"', DISABLED, DISABLED, true, true, false, true, "\r\n");
54+
public static final CSVFormat DEFAULT = new CSVFormat(',', '"', DISABLED, DISABLED, true, true, false, true, CRLF);
5355

5456
/**
5557
* Excel file format (using a comma as the value delimiter).
@@ -62,10 +64,10 @@ public class CSVFormat implements Serializable {
6264
*
6365
* <pre>CSVFormat fmt = CSVFormat.EXCEL.withDelimiter(';');</pre>
6466
*/
65-
public static final CSVFormat EXCEL = new CSVFormat(',', '"', DISABLED, DISABLED, false, false, false, false, "\r\n");
67+
public static final CSVFormat EXCEL = new CSVFormat(',', '"', DISABLED, DISABLED, false, false, false, false, CRLF);
6668

6769
/** Tab-delimited format, with quote; leading and trailing spaces ignored. */
68-
public static final CSVFormat TDF = new CSVFormat('\t', '"', DISABLED, DISABLED, true, true, false, true, "\r\n");
70+
public static final CSVFormat TDF = new CSVFormat('\t', '"', DISABLED, DISABLED, true, true, false, true, CRLF);
6971

7072
/**
7173
* Default MySQL format used by the <tt>SELECT INTO OUTFILE</tt> and

0 commit comments

Comments
 (0)