instance method
encode_params
Ruby on Rails 3.0.20
Since v3.0.20 Last seen in v3.2.22.5 PrivateSignature
encode_params(params)
TODO: Validate that the characters are UTF-8. If they aren’t, you’ll get a weird error down the road, but our form handling should really prevent that from happening
Parameters
-
paramsreq
Source
# File actionpack/lib/action_dispatch/http/parameters.rb, line 43
def encode_params(params)
return params unless "ruby".encoding_aware?
if params.is_a?(String)
return params.force_encoding("UTF-8").encode!
elsif !params.is_a?(Hash)
return params
end
params.each do |k, v|
case v
when Hash
encode_params(v)
when Array
v.map! {|el| encode_params(el) }
else
encode_params(v)
end
end
end
Defined in actionpack/lib/action_dispatch/http/parameters.rb line 43
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionDispatch::Http::Parameters