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#unescape_uri_component

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

Alias of #unescapeURIComponent

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

Example
string = CGI.unescapeURIComponent("%27Stop%21%27+said%20Fred")
   # => "'Stop!'+said Fred"