Ruby latest stable (v2_5_5) - 0 notes - Class: URI
decode_www_form(str, enc=Encoding::UTF_8, separator: '&', use__charset_: false, isindex: false) public

Decode URL-encoded form data from given str.

This decodes application/x-www-form-urlencoded data and returns array of key-value array.

This refers , so this supports only &-separator, don’t support ;-separator.

ary = URI.decode_www_form("a=1&a=2&b=3")
p ary                  #=> [['a', '1'], ['a', '2'], ['b', '3']]
p ary.assoc('a').last  #=> '1'
p ary.assoc('b').last  #=> '3'
p ary.rassoc('a').last #=> '2'
p Hash[ary]            # => {"a"=>"2", "b"=>"3"}

See URI.decode_www_form_component, URI.encode_www_form

Show source
Register or log in to add new notes.