From 03c2ee26f9daa4206eb9bb28980161d15a2b830e Mon Sep 17 00:00:00 2001 From: naruse Date: Sun, 24 Aug 2008 03:21:36 +0000 Subject: * lib/net/http.rb (Net::HTTP#urlencode): str[0] returns char in 1.9. Patch by Junegunn Choi [ruby-core:18368] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/net/http.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/net/http.rb b/lib/net/http.rb index b3ddee54e..8e0c3b208 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -1526,7 +1526,7 @@ module Net #:nodoc: private :encode_kvpair def urlencode(str) - str.gsub(/[^a-zA-Z0-9_\.\-]/n) { sprintf('%%%02x', $&[0]) } + str.dup.force_encoding('ASCII-8BIT').gsub(/[^a-zA-Z0-9_\.\-]/){'%%%02x' % $&.ord} end private :urlencode -- cgit