本文簡要介紹ruby語言中 URI.encode_www_form
的用法。
用法
encode_www_form(enum, enc=nil)
從給定的 enum
生成 URL 編碼的表單數據。
這會從給定的 Enumerable
對象生成 HTML5 中定義的 application/x-www-form-urlencoded 數據。
這在內部使用 URI.encode_www_form_component(str)
。
此方法不會轉換給定項目的編碼,因此如果要發送原始編碼或混合編碼數據以外的數據,請在調用此方法之前對其進行轉換。 (以 HTML5 ASCII 不兼容編碼編碼的字符串將轉換為 UTF-8。)
此方法不處理文件。發送文件時,請使用 multipart/form-data。
這是指url.spec.whatwg.org/#concept-urlencoded-serializer
URI.encode_www_form([["q", "ruby"], ["lang", "en"]])
#=> "q=ruby&lang=en"
URI.encode_www_form("q" => "ruby", "lang" => "en")
#=> "q=ruby&lang=en"
URI.encode_www_form("q" => ["ruby", "perl"], "lang" => "en")
#=> "q=ruby&q=perl&lang=en"
URI.encode_www_form([["q", "ruby"], ["q", "perl"], ["lang", "en"]])
#=> "q=ruby&q=perl&lang=en"
相關用法
- Ruby URI.extract用法及代碼示例
- Ruby URI.parse用法及代碼示例
- Ruby URI.join用法及代碼示例
- Ruby URI.decode_www_form用法及代碼示例
- Ruby URI.regexp用法及代碼示例
- Ruby URI.split用法及代碼示例
- Ruby URI模塊用法及代碼示例
- Ruby UndefinedConversionError.source_encoding用法及代碼示例
- Ruby UnboundMethod.original_name用法及代碼示例
- Ruby UID.change_privilege用法及代碼示例
- Ruby Util.unescape用法及代碼示例
- Ruby Util.url_encode用法及代碼示例
- Ruby UNIXSocket.new用法及代碼示例
- Ruby UNIXSocket.addr用法及代碼示例
- Ruby UnboundMethod.bind用法及代碼示例
- Ruby UNIXServer.accept用法及代碼示例
- Ruby UNIXSocket.recv_io用法及代碼示例
- Ruby UID.euid用法及代碼示例
- Ruby UncaughtThrowError類用法及代碼示例
- Ruby Util.pretty用法及代碼示例
- Ruby UID.uid用法及代碼示例
- Ruby UnwindDetails.all_requirements用法及代碼示例
- Ruby UnboundMethod類用法及代碼示例
- Ruby UnwindDetails.reversed_requirement_tree_index用法及代碼示例
- Ruby UnboundMethod.parameters用法及代碼示例
注:本文由純淨天空篩選整理自ruby-lang.org大神的英文原創作品 URI.encode_www_form。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。