Issue #5568 has been updated by Yui NARUSE.

Category set to M17N
Status changed from Open to Assigned
Assignee set to Yui NARUSE


----------------------------------------
Bug #5568: IO#set_encoding ignores internal when the same as external only when specified as "ext:int"
http://redmine.ruby-lang.org/issues/5568

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


When passing two encoding objects that are the same to IO#set_encoding, both external and internal encodings for the IO instance are set.

However, when passing "ext:int", the internal encoding is not set if the same as external, but a warning is issued. Further, when passing "ext", "int", the internal encoding is not set and no warning is issued.

sasha:rubinius brian$ ruby2.0 -v -e 'p STDOUT.set_encoding("utf-8:utf-8").internal_encoding'
ruby 2.0.0dev (2011-10-26 trunk 33526) [x86_64-darwin10.8.0]
-e:1: warning: Ignoring internal encoding utf-8: it is identical to external encoding utf-8
nil

sasha:rubinius brian$ ruby2.0 -v -e 'p STDOUT.set_encoding(Encoding::UTF_8, Encoding::UTF_8).internal_encoding'
ruby 2.0.0dev (2011-10-26 trunk 33526) [x86_64-darwin10.8.0]
#<Encoding:UTF-8>

sasha:rubinius brian$ ruby2.0 -v -e 'p STDOUT.set_encoding("utf-8", "utf-8").internal_encoding'
ruby 2.0.0dev (2011-10-26 trunk 33526) [x86_64-darwin10.8.0]
nil

Is there a reason for these differences?

Thanks,
Brian


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