Project

General

Profile

Bug #1375

Zlib::GzipReaderに対するエンコーディング指定

Added by sakuro (Sakuro OZAWA) about 10 years ago. Updated about 8 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 1.9.2dev (2009-04-12 trunk 23171) [i386-darwin9.6.1]
Backport:
[ruby-dev:38304]

Description

=begin
Zlib::GzipReaderでエンコーディングを指定しても効果がないようですが、これはそういうもので、
読んだ結果を適宜エンコーディングするのが正しいやり方でしょうか。

$irb -rzlib --prompt=simple

RUBY_VERSION
=> "1.9.2"
Encoding.default_external
=> #Encoding:UTF-8
gz = Zlib::GzipReader.open('test.txt.gz', 'r:UTF-8')
ArgumentError: wrong number of arguments (2 for 1)
from (irb):3:in initialize'
from (irb):3:in
open'
from (irb):3
from /usr/local/bin/irb:12:in <main>'
gz = Zlib::GzipReader.open('test.txt.gz', encoding: 'UTF-8')
=> #<Zlib::GzipReader:0x2f0800>
str = gz.read
=> "\xE3\x81\x93\xE3\x82\x93\xE3\x81\xAB\xE3\x81\xA1\xE3\x81\xAF\xE4\xB8\x96\xE7\x95\x8C\n"
str.force_encoding 'UTF-8'
=> "こんにちは世界\n"
gz.set_encoding 'UTF-8'
NoMethodError: undefined method
set_encoding' for #Zlib::GzipReader:0x2f0800
from (irb):5
from /usr/local/bin/irb:12:in `'
=end

Associated revisions

Revision a2ba489e
Added by hsbt (Hiroshi SHIBATA) over 3 years ago

  • lib/rubygems: Update to RubyGems 2.5.0+ HEAD(db78980). this version includes #1367 , #1373 , #1375
  • test/rubygems: ditto.

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

Revision 52546
Added by hsbt (Hiroshi SHIBATA) over 3 years ago

  • lib/rubygems: Update to RubyGems 2.5.0+ HEAD(db78980). this version includes #1367 , #1373 , #1375
  • test/rubygems: ditto.

Revision 52546
Added by hsbt (Hiroshi SHIBATA) over 3 years ago

  • lib/rubygems: Update to RubyGems 2.5.0+ HEAD(db78980). this version includes #1367 , #1373 , #1375
  • test/rubygems: ditto.

Revision 52546
Added by hsbt (Hiroshi SHIBATA) over 3 years ago

  • lib/rubygems: Update to RubyGems 2.5.0+ HEAD(db78980). this version includes #1367 , #1373 , #1375
  • test/rubygems: ditto.

Revision 52546
Added by hsbt (Hiroshi SHIBATA) over 3 years ago

  • lib/rubygems: Update to RubyGems 2.5.0+ HEAD(db78980). this version includes #1367 , #1373 , #1375
  • test/rubygems: ditto.

Revision 52546
Added by hsbt (Hiroshi SHIBATA) over 3 years ago

  • lib/rubygems: Update to RubyGems 2.5.0+ HEAD(db78980). this version includes #1367 , #1373 , #1375
  • test/rubygems: ditto.

Revision 5f671527
Added by hsbt (Hiroshi SHIBATA) over 3 years ago

  • lib/rubygems: Update to RubyGems 2.5.0+ HEAD(c6b4946). this version includes #1114, #1314, #1322, #1375, #1383, #1387
  • test/rubygems: ditto.

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

Revision 52666
Added by hsbt (Hiroshi SHIBATA) over 3 years ago

  • lib/rubygems: Update to RubyGems 2.5.0+ HEAD(c6b4946). this version includes #1114, #1314, #1322, #1375, #1383, #1387
  • test/rubygems: ditto.

Revision 52666
Added by hsbt (Hiroshi SHIBATA) over 3 years ago

  • lib/rubygems: Update to RubyGems 2.5.0+ HEAD(c6b4946). this version includes #1114, #1314, #1322, #1375, #1383, #1387
  • test/rubygems: ditto.

Revision 52666
Added by hsbt (Hiroshi SHIBATA) over 3 years ago

  • lib/rubygems: Update to RubyGems 2.5.0+ HEAD(c6b4946). this version includes #1114, #1314, #1322, #1375, #1383, #1387
  • test/rubygems: ditto.

Revision 52666
Added by hsbt (Hiroshi SHIBATA) over 3 years ago

  • lib/rubygems: Update to RubyGems 2.5.0+ HEAD(c6b4946). this version includes #1114, #1314, #1322, #1375, #1383, #1387
  • test/rubygems: ditto.

Revision 52666
Added by hsbt (Hiroshi SHIBATA) over 3 years ago

  • lib/rubygems: Update to RubyGems 2.5.0+ HEAD(c6b4946). this version includes #1114, #1314, #1322, #1375, #1383, #1387
  • test/rubygems: ditto.

History

#1

Updated by yugui (Yuki Sonoda) almost 10 years ago

  • Assignee set to naruse (Yui NARUSE)

=begin

=end

#2

Updated by naruse (Yui NARUSE) over 9 years ago

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

=begin
Applied in changeset r24704.
=end

#3

Updated by naruse (Yui NARUSE) over 9 years ago

=begin
設定方法は
Zlib::GzipReader.open('test.txt.gz', encoding: 'UTF-8')
であっています。

Zlib::GzipReader#read では設定されたエンコーディングが反映されない、というのがこのバグでした。
=end

Also available in: Atom PDF