Project

General

Profile

Bug #3058

Inconsistent eol conversion of IO#read on Windows

Added by phasis68 (Heesob Park) over 10 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
ruby -v:
ruby 1.9.2dev (2010-03-31 trunk 27123) [i386-mswin32_90]
Backport:
[ruby-core:29161]

Description

=begin
I found that IO#read(length) don't convert "\r\n" to "\n" on 1.9.x

On ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]

irb(main):001:0> File.open('test.txt','r').read
=> "test\n"
irb(main):002:0> File.open('test.txt','rb').read
=> "test\r\n"
irb(main):003:0> File.open('test.txt','r').read(8)
=> "test\n"
irb(main):004:0> File.open('test.txt','rb').read(8)
=> "test\r\n"

On ruby 1.9.2dev (2010-03-31 trunk 27123) [i386-mswin32_90]

irb(main):001:0> File.open('test.txt','r').read
=> "test\n"
irb(main):002:0> File.open('test.txt','rb').read
=> "test\r\n"
irb(main):003:0> File.open('test.txt','r').read(8)
=> "test\r\n"
irb(main):004:0> File.open('test.txt','rb').read(8)
=> "test\r\n"

I think that File.open('test.txt','r').read(8) should be "test\n".
=end

#1

Updated by matz (Yukihiro Matsumoto) over 10 years ago

=begin
Hi,

In message "Re: [ruby-core:29161] [Bug #3058] Inconsistent eol conversion of IO#read on Windows"
on Wed, 31 Mar 2010 18:37:35 +0900, Heesob Park redmine@ruby-lang.org writes:

|I found that IO#read(length) don't convert "\r\n" to "\n" on 1.9.x

On 1.9, newline conversion has moved from stdin wrapper to encoding
translation layer, which stop working on binary read, so it's intended
feature.

                        matz.

=end

#2

Updated by phasis68 (Heesob Park) over 10 years ago

=begin
Hi,

2010/4/5 Yukihiro Matsumoto matz@ruby-lang.org:

Hi,

In message "Re: [ruby-core:29161] [Bug #3058] Inconsistent eol conversion of IO#read on Windows"
   on Wed, 31 Mar 2010 18:37:35 +0900, Heesob Park redmine@ruby-lang.org writes:

|I found that IO#read(length) don't convert "\r\n" to "\n" on 1.9.x

On 1.9, newline conversion has moved from stdin wrapper to encoding
translation layer, which stop working on binary read, so it's intended
feature.

I understand the feature.
But, in that case, the document of ios.read(length [,buffer]])
must be stated the difference when length is present or omitted.

Regards,
Park Heesob

=end

#3

Updated by naruse (Yui NARUSE) over 10 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r27604.
Heesob, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Also available in: Atom PDF