Project

General

Profile

Bug #5567

IO#set_encoding ignores one invalid encoding unless a second argument is passed

Added by brixen (Brian Shirai) over 7 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:40726]

Description

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
'

Is this intentional?

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

Thanks,
Brian

Associated revisions

Revision 33ceea5c
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • encoding.c (rb_find_encoding): new function find encoding from arbitrary object as a pointer to rb_encoding, and return NULL if not found.
  • io.c (io_encoding_set): just warn unsupported encodings, but not exception. [ruby-core:40726] [Bug #5567]

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

Revision 34986
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • encoding.c (rb_find_encoding): new function find encoding from arbitrary object as a pointer to rb_encoding, and return NULL if not found.
  • io.c (io_encoding_set): just warn unsupported encodings, but not exception. [ruby-core:40726] [Bug #5567]

Revision 34986
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • encoding.c (rb_find_encoding): new function find encoding from arbitrary object as a pointer to rb_encoding, and return NULL if not found.
  • io.c (io_encoding_set): just warn unsupported encodings, but not exception. [ruby-core:40726] [Bug #5567]

Revision 34986
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • encoding.c (rb_find_encoding): new function find encoding from arbitrary object as a pointer to rb_encoding, and return NULL if not found.
  • io.c (io_encoding_set): just warn unsupported encodings, but not exception. [ruby-core:40726] [Bug #5567]

Revision 34986
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • encoding.c (rb_find_encoding): new function find encoding from arbitrary object as a pointer to rb_encoding, and return NULL if not found.
  • io.c (io_encoding_set): just warn unsupported encodings, but not exception. [ruby-core:40726] [Bug #5567]

Revision 34986
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • encoding.c (rb_find_encoding): new function find encoding from arbitrary object as a pointer to rb_encoding, and return NULL if not found.
  • io.c (io_encoding_set): just warn unsupported encodings, but not exception. [ruby-core:40726] [Bug #5567]

Revision 34986
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • encoding.c (rb_find_encoding): new function find encoding from arbitrary object as a pointer to rb_encoding, and return NULL if not found.
  • io.c (io_encoding_set): just warn unsupported encodings, but not exception. [ruby-core:40726] [Bug #5567]

History

Updated by ko1 (Koichi Sasada) over 7 years ago

  • Category set to core
  • Assignee set to naruse (Yui NARUSE)
#2

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

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

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


  • encoding.c (rb_find_encoding): new function find encoding from arbitrary object as a pointer to rb_encoding, and return NULL if not found.
  • io.c (io_encoding_set): just warn unsupported encodings, but not exception. [ruby-core:40726] [Bug #5567]

Also available in: Atom PDF