るりまサーチ

最速Rubyリファレンスマニュアル検索!
11件ヒット [1-11件を表示] (0.408秒)
トップページ > クエリ:I[x] > クエリ:rassoc[x] > クエリ:decode_www_form[x]

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

モジュール

検索結果

URI.decode_www_form(str, enc=Encoding::UTF_8) -> [[String, String]] (21419.0)

文字列から URL-encoded form data をデコードします。

...文字列から URL-encoded form data をデコードします。

application/x-www-form-urlencoded 形式のデータをデコードし、
[key, value] という形の配列の配列を返します。

enc で指定したエンコーディングの文字列が URL エンコードされたもの...
...区切りには対応していません。

require 'uri'
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"}

@param str デコード対象の文字列
@param enc エンコーディング
@raise ArgumentError str のフォーマットが不正である場合に発生します
@see URI.decode_www_form_component, URI.encode_www_form...