From: Florian Gilcher Date: 2008-03-01T03:10:52+09:00 Subject: Re: Convert characters from hex to string On Feb 29, 2008, at 7:06 PM, Shandy Nantz wrote: > I looked around and found some similar postings to my problem but not > exactly what I was looking for. I have a string that has some hex > characters intermingled in with a normal string. I need to convert > those > character in their char equivalent. unpack seems not to work. My > string > looks like this: > > https%3A%2F%2Fwww.example.com%2Flogic%3Fss%3D1%26companyname > %3DShhhhhhh%26userlogin%3Dshhhhh%40 > > > Is there a way to do this? Thanks, > > -S > -- > Posted via http://www.ruby-forum.com/. > This is obviously an url-encoded string. So, the CGI-Library is you saviour: ==== code ==== require 'cgi' CGI.unescape('https%3A%2F%2Fwww.example.com%2Flogic%3Fss %3D1%26companyname%3DShhhhhhh%26userlogin%3Dshhhhh%40') # => "https://www.example.com/logic?ss=1&companyname=Shhhhhhh&userlogin=shhhhh@ \n" ==== code ==== Greetings Florian Gilcher