Skip to content

Commit 4c0fc6c

Browse files
committed
ignore CRLF/LF difference
continues #40
1 parent 25bbf4e commit 4c0fc6c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/fileio.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function loadfile(T, file::File)
99
end
1010

1111
function loadfile(T, file::TextFile)
12-
replace(read(file.filename, String), "\r"=>"")
12+
replace(read(file.filename, String), "\r"=>"") # ignore CRLF/LF difference
1313
end
1414

1515
function loadfile(::Type{<:Number}, file::File{format"TXT"})
@@ -46,7 +46,7 @@ Convert `x` to a validate content for file data format `T`.
4646
_convert(::Type{<:DataFormat}, x; kw...) = x
4747

4848
# plain TXT
49-
_convert(::Type{DataFormat{:TXT}}, x; kw...) = string(x)
49+
_convert(::Type{DataFormat{:TXT}}, x; kw...) = replace(string(x), "\r"=>"") # ignore CRLF/LF difference
5050
_convert(::Type{DataFormat{:TXT}}, x::Number; kw...) = x
5151
function _convert(::Type{DataFormat{:TXT}}, x::AbstractArray{<:AbstractString}; kw...)
5252
return join(x, '\n')

test/runtests.jl

+4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ end
5757
@test_reference "references/string3.txt" 1338 by=(ref, x)->isapprox(ref, x; atol=10)
5858
@test_reference "references/string4.txt" strip_summary(@io2str show(::IO, MIME"text/plain"(), Int64.(collect(1:5))))
5959

60+
# ignore CRLF/LF differences
61+
@test_reference "references/string5.txt" """
62+
This is a\r
63+
multiline string that does not end with a new line."""
6064
@test_reference "references/string5.txt" """
6165
This is a
6266
multiline string that does not end with a new line."""

0 commit comments

Comments
 (0)