Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

CGI::Escape#unescapeURIComponent

(::string) -> ::String
unescapeURIComponent(string, encoding = @@accept_charset)

URL-decode a string following RFC 3986 with encoding(optional).

Example
string = CGI.unescapeURIComponent("%27Stop%21%27+said%20Fred")
   # => "'Stop!'+said Fred"
See also #unescape_uri_component #unescapeHTML also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1