URLDecoder

How to decode/unescape a URL encoded string in Ruby

by Venelin K. · 1 MIN

You can use Ruby's CGI::Unescape method to unescape or decode a URL encoded string. Let's see an example of URL decoding in Ruby.

URL decoding a string in Ruby

require 'cgi'

url_encoded_string = CGI.escape("Coder's Paradise@Ruby") # Coder%27s+Paradise%40Ruby

decoded_string = CGI.unescape(url_encoded_string) # Coder's Paradise@Ruby

Also Read: How to URL Encode a String in Ruby

References

Share on social media