diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | lib/open-uri.rb | 7 |
2 files changed, 11 insertions, 0 deletions
@@ -1,3 +1,7 @@ +Sun Oct 5 17:49:35 2008 NARUSE, Yui <naruse@ruby-lang.org> + + * lib/open-uri.rb (OpenURI.open_uri): set encoding to strio. + Sun Oct 5 17:39:21 2008 NARUSE, Yui <naruse@ruby-lang.org> * ext/stringio/stringio.c (strio_set_encoding): defined for diff --git a/lib/open-uri.rb b/lib/open-uri.rb index c68aee6e97..03f5e6de4e 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -132,6 +132,11 @@ module OpenURI options ||= {} OpenURI.check_options(options) + if /\Arb?(?:\Z|:([^:]+))/ =~ mode + encoding, = $1,Encoding.find($1) if $1 + mode = nil + end + unless mode == nil || mode == 'r' || mode == 'rb' || mode == File::RDONLY @@ -139,6 +144,8 @@ module OpenURI end io = open_loop(uri, options) + io.set_encoding(encoding) if encoding + p [encoding, io.external_encoding] if block_given? begin yield io |