Bug #3058

Inconsistent eol conversion of IO#read on Windows

Added by phasis68 (Heesob Park) about 2 years ago. Updated about 1 year ago.

[ruby-core:29161]
Status:Closed Start date:03/31/2010
Priority:Normal Due date:
Assignee:- % Done:

100%

Category:core
Target version:1.9.2
ruby -v:ruby 1.9.2dev (2010-03-31 trunk 27123) [i386-mswin32_90]

Description

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".

Associated revisions

Revision 27604
Added by naruse (Yui NARUSE) about 2 years ago

Add rdoc about IO#read(length). [ruby-core:29161]

History

Updated by matz (Yukihiro Matsumoto) about 2 years ago

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.

Updated by phasis68 (Heesob Park) about 2 years ago

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

Updated by naruse (Yui NARUSE) about 2 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100
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.

Also available in: Atom PDF