Project

General

Profile

Bug #5568

IO#set_encoding ignores internal when the same as external only when specified as "ext:int"

Added by brixen (Brian Shirai) almost 8 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 2.0.0dev (2011-10-26 trunk 33526) [x86_64-darwin10.8.0]
Backport:
[ruby-core:40727]

Description

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


Related issues

Related to Ruby master - Bug #6324: Spurious/incorrect warning on File.open with internal_encoding specified in string mode to duplicate external_encodingClosed04/20/2012Actions

Associated revisions

Revision db83618d
Added by naruse (Yui NARUSE) over 7 years ago

  • io.c (io_encoding_set): always warn if external encoding and internal encoding are identical. [ruby-core:40727] [Bug #5568]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 34997
Added by naruse (Yui NARUSE) over 7 years ago

  • io.c (io_encoding_set): always warn if external encoding and internal encoding are identical. [ruby-core:40727] [Bug #5568]

Revision 34997
Added by naruse (Yui NARUSE) over 7 years ago

  • io.c (io_encoding_set): always warn if external encoding and internal encoding are identical. [ruby-core:40727] [Bug #5568]

Revision 34997
Added by naruse (Yui NARUSE) over 7 years ago

  • io.c (io_encoding_set): always warn if external encoding and internal encoding are identical. [ruby-core:40727] [Bug #5568]

Revision 34997
Added by naruse (Yui NARUSE) over 7 years ago

  • io.c (io_encoding_set): always warn if external encoding and internal encoding are identical. [ruby-core:40727] [Bug #5568]

Revision 34997
Added by naruse (Yui NARUSE) over 7 years ago

  • io.c (io_encoding_set): always warn if external encoding and internal encoding are identical. [ruby-core:40727] [Bug #5568]

Revision 34997
Added by naruse (Yui NARUSE) over 7 years ago

  • io.c (io_encoding_set): always warn if external encoding and internal encoding are identical. [ruby-core:40727] [Bug #5568]

History

Updated by naruse (Yui NARUSE) almost 8 years ago

  • Category set to M17N
  • Status changed from Open to Assigned
  • Assignee set to naruse (Yui NARUSE)

Updated by naruse (Yui NARUSE) almost 8 years ago

  • Status changed from Assigned to Rejected

Current behavior is correct.
It means the specifying internal encoding won't effect until external encoding is changed.

Updated by brixen (Brian Shirai) almost 8 years ago

Why is there a difference in behavior when the arguments are different? In other words, ("ext:int") and (ext, int) do not have the same behavior. That's really the point of this ticket.

Updated by naruse (Yui NARUSE) almost 8 years ago

  • Status changed from Rejected to Assigned
#5

Updated by naruse (Yui NARUSE) over 7 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r34997.
Brian, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • io.c (io_encoding_set): always warn if external encoding and internal encoding are identical. [ruby-core:40727] [Bug #5568]

Also available in: Atom PDF