From d931e06f45580cc3e066a9056df1d9c15c28d15d Mon Sep 17 00:00:00 2001 From: naruse Date: Sun, 5 Oct 2008 08:51:22 +0000 Subject: * lib/open-uri.rb (OpenURI.open_uri): set encoding to strio. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/open-uri.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib') diff --git a/lib/open-uri.rb b/lib/open-uri.rb index c68aee6e9..03f5e6de4 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 -- cgit