Project

General

Profile

Actions

Bug #1375

closed

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

Added by sakuro (Sakuro OZAWA) almost 15 years ago. Updated almost 13 years ago.

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

Actions #1

Updated by yugui (Yuki Sonoda) over 14 years ago

  • Assignee set to naruse (Yui NARUSE)

=begin

=end

Actions #2

Updated by naruse (Yui NARUSE) over 14 years ago

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

=begin
Applied in changeset r24704.
=end

Actions #3

Updated by naruse (Yui NARUSE) over 14 years ago

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

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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0