dashbitco / nimble_csv

A simple and fast CSV parsing and dumping library for Elixir
https://hexdocs.pm/nimble_csv
772 stars 51 forks source link

NimbleCSV.RFC4180.dump* is using `\n` instead of `\r\n` #58

Closed unthought closed 4 years ago

unthought commented 4 years ago

The spec states that the line separator must be be \r\n, but it's currently using the default value \n.

https://tools.ietf.org/html/rfc4180#section-2

  1. Each record is located on a separate line, delimited by a line break (CRLF).

CR = %x0D ;as per section 6.1 of RFC 2234 LF = %x0A ;as per section 6.1 of RFC 2234 CRLF = CR LF ;as per section 6.1 of RFC 2234

workaround (and fix):

  NimbleCSV.define(NimbleCSV.RFC4180fixed,
    separator: ",",
    escape: "\"",
    line_separator: "\r\n",
    moduledoc: """
    A CSV parser that uses comma as separator and double-quotes as escape according to RFC4180.
    """
  )
josevalim commented 4 years ago

Good catch, fixed on v1.1.0.