func urlencode(str) { str.gsub!(%r"([^-A-Za-z0-9_.!~*'() ])", {|a| "%%%02X" % a.ord }) str.gsub!(' ', '+') return str } say urlencode('http://foo bar/')
http%3A%2F%2Ffoo+bar%2F
Last updated 1 year ago