From: 7stud -- Date: 2009-10-11T13:53:48+09:00 Subject: Re: Can't use variable from cgi with hpricot Wiley Davis wrote: > I'm trying to get a url from a form and return the page title of said > url. I'm using cgi to get the web address from the url, which looks like > this: > > http%3A%2F%2Fpracticalpedal.com > > > @linky = "http://practicalpedal.com" > A cursory examination of those strings reveals that they are not identical. > This works if I assign the @linky variable like so: > @linky = "http://practicalpedal.com" ...and what about: @linky = "http%3A%2F%2Fpracticalpedal.com" ?? That's the string you are getting from cgi. You can test that by writing @linky to a .txt file and then examining the contents of the file. require 'cgi' str = "http://practicalpedal.com" new_str = CGI.escape(str) p new_str --output:-- "http%3A%2F%2Fpracticalpedal.com" Look familiar? x = CGI.unescape(new_str) p x --output:-- "http://practicalpedal.com" The rule: certain characters have to be 'transformed' in order to pass them in a query string attached to the end of a url. That means the special characters have to be 'untransformed' on the other side. -- Posted via http://www.ruby-forum.com/.