Bug #1689: ARGF.binmode Affects Encoding Inconsistently
http://redmine.ruby-lang.org/issues/show/1689
Author: Run Paint Run Run
Status: Open, Priority: Low
Category: M17N
ruby -v: ruby 1.9.2dev (2009-06-21 trunk 23774) [i686-linux]
The IO#binmode documentation promises that "content is treated as
ASCII-8BIT". I assumed this would apply to ARGF, too. It sometimes does:
$ echo "a" | ruby -ve 'ARGF.binmode; p ARGF.readpartial(1).encoding'
ruby 1.9.2dev (2009-06-21 trunk 23774) [i686-linux]
#<Encoding:ASCII-8BIT>
But often doesn't:
$ echo "a" | ruby -ve 'ARGF.binmode; p ARGF.read.encoding'
ruby 1.9.2dev (2009-06-21 trunk 23774) [i686-linux]
#<Encoding:UTF-8>
$ echo "a" | ruby -ve 'ARGF.binmode; p ARGF.getc.encoding'
ruby 1.9.2dev (2009-06-21 trunk 23774) [i686-linux]
#<Encoding:UTF-8>
$ echo "a" | ruby -ve 'ARGF.binmode; p ARGF.readchar.encoding'
ruby 1.9.2dev (2009-06-21 trunk 23774) [i686-linux]
#<Encoding:UTF-8>
$ ruby -ve 'ARGF.binmode; p ARGF.read.encoding' /usr/bin/ruby
ruby 1.9.2dev (2009-06-21 trunk 23774) [i686-linux]
#<Encoding:UTF-8>
I had assumed that ARGF.binmode would set the encoding of all files read
in to ASCII-8BIT. This is how, for instance, File works: File.binmode
sets the output of File.read to ASCII-8BIT, even when the contents is
entirely ASCII. Setting the default external encoding to ASCII-8BIT
fixes these cases.
So. given that I'm trying to document ARGF, my questions are:
1) Why the inconsistency between ARGF.readpartial and the rest of the
ARGF methods?
2) Should the default external encoding take precedence over 'binmode'?
on 2009-06-25 10:16
on 2009-06-25 11:07
Issue #1689 has been updated by Yukihiro Matsumoto. Status changed from Open to Closed % Done changed from 0 to 100 Applied in changeset r23853. ---------------------------------------- http://redmine.ruby-lang.org/issues/show/1689
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.