зеркало из https://github.com/github/ruby.git
* lib/open-uri.rb (OpenURI.open_uri): set encoding to strio.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
fd898245cb
Коммит
f09149cab5
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче