Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

CSV encode double-escapes escape codes like CR #70

Closed
karmajunkie opened this issue Sep 1, 2017 · 3 comments
Closed

CSV encode double-escapes escape codes like CR #70

karmajunkie opened this issue Sep 1, 2017 · 3 comments

Comments

@karmajunkie
Copy link

When encoding a line which contains a field with an embedded escape code, CSV escapes the backslash, so the output contains \r\n instead of a CRLF. This is an issue with double-quoted fields which are allowed to have CRLF's embedded. See below:

iex(9)> IO.puts "foo\r\nbar"
foo
bar
:ok
iex(10)> [["foo\r\nbar", "foo", "bar"]] |> CSV.encode |> Enum.to_list
["\"foo\\r\\nbar\",foo,bar\r\n"]

I can work around it by regex removing the escaped backslash, but unless I'm missing something this is incorrect behavior.

@beatrichartz
Copy link
Owner

Thanks for raising this, will have a look at a fix soon.

@chingan-tsc
Copy link

Am having exactly the same issue and my temporary fix is something like String.replace("\\n", "\n").

@beatrichartz
Copy link
Owner

Hey all, this is fixed in 2.4.1 - feel free to reopen if issues persist.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants