Skip to content

File.open ignores :universal_newline options on Windows #3736

@enebo

Description

@enebo

Environment

both jruby 1.7.24 and JRuby 9.0.5.0 have this issue.

Expected Behavior

A file which contains \r\n should still retain the \r\n and not convert to \n if universal_newline is false.

require 'csv'
require "tempfile"

@tempfile = Tempfile.new(%w"temp .csv")
@tempfile.close
@path = @tempfile.path

File.open(@path, "wb") do |file|
  file << "1\t2\t3\r\n"
  file << "4\t5\r\n"
end

f = File.open(@path, {:universal_newline=>false})
p f.gets

Actual Behavior

We seem to always return \n as delimiter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions