Skip to content

Commit a5d36ed

Browse files
authored
Merge pull request #1484 from bonjune/rfc-4180
2 parents 13afb37 + d0a9884 commit a5d36ed

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/FSharp.Data.Csv.Core/CsvRuntime.fs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,11 @@ type CsvFile<'RowType>
447447

448448
use writer = writer
449449

450+
// RFC 4180 (https://www.rfc-editor.org/rfc/rfc4180)
451+
// 2. Definition of the CSV Format
452+
// Each record is located on a separated line, delimited by a line break CRLF
453+
writer.NewLine <- "\r\n"
454+
450455
let nullSafeguard str =
451456
match str with
452457
| null -> String.Empty

tests/FSharp.Data.Tests/CsvProvider.fs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ let ``Can create type for small document``() =
124124

125125
[<Test>]
126126
let ``CsvFile.Rows is re-entrant if the underlying stream is``() =
127-
let csv = CsvFile.Load(Path.Combine(__SOURCE_DIRECTORY__, "Data/SmallTest.csv"))
127+
let csv = CsvFile.Load(Path.Combine(__SOURCE_DIRECTORY__, "Data/SmallTest.csv"))
128128
let twice = [ yield! csv.Rows; yield! csv.Rows ]
129129
twice |> Seq.length |> should equal 6
130130

@@ -465,7 +465,8 @@ let ``Parse single row with trailing newline``() =
465465
let ``Parse two rows``() =
466466
let rows = SimpleWithStrCsv.ParseRows("false,abc, 31\ntrue, def, 42")
467467
rows.Length |> should equal 2
468-
(new SimpleWithStrCsv(rows)).SaveToString() |> should equal ("Column1,ColumnB,Column3" + Environment.NewLine + "false,abc,31" + Environment.NewLine + "true, def,42" + Environment.NewLine)
468+
(new SimpleWithStrCsv(rows)).SaveToString() |> should equal ("Column1,ColumnB,Column3" + "\r\n" + "false,abc,31" + "\r\n" + "true, def,42" + "\r\n")
469+
// (new SimpleWithStrCsv(rows)).SaveToString() |> should equal ("Column1,ColumnB,Column3" + Environment.NewLine + "false,abc,31" + Environment.NewLine + "true, def,42" + Environment.NewLine)
469470

470471
let [<Literal>] csvWithDataEndingWithSeparator = """
471472
Name|Company |Email|Password

0 commit comments

Comments
 (0)