2010/7/22 Dreamcat Four <redmine / ruby-lang.org>:
> Well I was unaware of this. In that case the argument Bill has can be seen as an issue.
> Reading a file with the IO object would read the ASCII tags, and you wouldn't know what to do.
> The tags map to both Ascii 7-bit and ascii 8-bit anyway.

It says People often treat a part of binary string as ASCII.

> It seems that the correct thing to do when reading a file through an IO object is set
> the encoding to Encoding::BINARY and ignore the ascii tags.
> Unless the ASCII tag says its a text file, then set the Encoding to ASCII.
> Thats pretty easy really.

Ruby is practical language; We want to write
  ruby -e'p IO.binread("foo.gif")[0,3]=="GIF"'
don't want
  ruby -e'p IO.binread("foo.gif")[0,3].force_encoding("US-ASCII")=="GIF"'

> What prompted me to report this:
>
> Translating data from a Ruby hash object and simple Ruby types into a Plist representation.
> To give users a standard and appropriate way to differentiate between their Ruby strings
> which are either textual (ascii or unicode), and their persistent binary data.
> A StringIO object is clearly not intended to represent a stream of binary data,
> since you have declared a specific Encoding::BINARY.
>
> There is simply no compelling argument why Encoding::BINARY should be an alias of 8-bit ASCII.

There are three encoding types: Unicode, ASCII, BINARY.
You should map as following:
Unicode: related Unicode encoding
ASCII: US-ASCII
BINARY: ASCII-8BIT

Or something bad may happen when you map as above?

-- 
NARUSE, Yui
naruse / airemix.jp