Project

General

Profile

Actions

Bug #5567

closed

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

Added by brixen (Brian Shirai) over 12 years ago. Updated about 12 years ago.

Status:
Closed
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

Updated by ko1 (Koichi Sasada) about 12 years ago

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

Updated by nobu (Nobuyoshi Nakada) about 12 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]
Actions

Also available in: Atom PDF

Like0
Like0Like0