22件ヒット
[1-22件を表示]
(0.367秒)
検索結果
先頭2件
-
URI
. decode _ www _ form(str , enc=Encoding :: UTF _ 8) -> [[String , String]] (21431.0) -
文字列から URL-encoded form data をデコードします。
...文字列から URL-encoded form data をデコードします。
application/x-www-form-urlencoded 形式のデータをデコードし、
[key, value] という形の配列の配列を返します。
enc で指定したエンコーディングの文字列が URL エンコードされたもの......ttps://url.spec.whatwg.org/#concept-urlencoded-parser
にもとづいて実装されています。
そのため「&」区切りのみに対応していて、「;」区切りには対応していません。
require 'uri'
ary = URI.decode_www_form("a=1&a=2&b=3")
p ary #=> [['......assoc('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... -
URI
. encode _ www _ form(enum , enc=nil) -> String (9255.0) -
enum から URL-encoded form data を生成します。
...RL-encoded form data を生成します。
HTML5 で定義されている application/x-www-form-urlencoded 形式の
文字列を生成します。
enum には通常 [key, value] という形の配列の配列を渡します。
以下の例を見てください。
require 'uri'
URI.encode_ww......# => "a=1&b=2&c=x+yz"
実際には、each のブロック呼び出しで [key, value] の形のデータを渡すものであれば
何でも渡すことができます(例えば Hash など)。
require 'uri'
URI.encode_www_form({"a"=>"1", "b"=>"2", "c"=>"x yz"})
# => "a=1&b=2&c=x+yz"......されています。
@param enum エンコードするデータ列([key, value] という形のデータの列)
@param enc 指定された場合、パーセントエンコーディングする前に、このエンコーディングに変換
@see URI.encode_www_form_component, URI.decode_www_form...