Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

CGI::Util#unescapeURIComponent

unescapeURIComponent(string, encoding = @@accept_charset)

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

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