Issue #5567 has been reported by Brian Ford.

----------------------------------------
Bug #5567: IO#set_encoding ignores one invalid encoding unless a second argument is passed
http://redmine.ruby-lang.org/issues/5567

Author: Brian Ford
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 2.0.0dev (2011-10-26 trunk 33526) [x86_64-darwin10.8.0] 


IO.set_encoding will ignore one invalid encoding unless a second argument is passed. This is odd behavior. See below:

sasha:rubinius brian$ ruby2.0 -v -e 'STDOUT.set_encoding("wtfzomgbbq")'
ruby 2.0.0dev (2011-10-26 trunk 33526) [x86_64-darwin10.8.0]
-e:1: warning: Unsupported encoding wtfzomgbbq ignored

BUT

sasha:rubinius brian$ ruby2.0 -v -e 'STDOUT.set_encoding("wtfzomgbbq", "wtf")'
ruby 2.0.0dev (2011-10-26 trunk 33526) [x86_64-darwin10.8.0]
-e:1:in `set_encoding': unknown encoding name - wtfzomgbbq (ArgumentError)
	from -e:1:in `<main>'

Is this intentional?

If this is fixed, please backport to 1.9.2 or 3.

Thanks,
Brian



-- 
http://redmine.ruby-lang.org