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:
I should clarify here - I am using RoR to do all of this. I had made a
post in the Rails forum but knowbody was answering. As for the
clarifying part, I am building this link in my controller and then
passing it to my view to be added into a link. The reason I do this is
that in my controller I generate a hash that is used to create an access
key for each user who is logging in, which becomes park of the link
string and then is passed to the view. However, the CGI.unescape isn’t
working.
=> "http://www.example.com/logic?
key for each user who is logging in, which becomes park of the link
string and then is passed to the view. However, the CGI.unescape isn’t
working.
So presumably you are building the string without escapes in the
controller. I suspect that it’s getting escaped after that, probably
in the view. How is the variable used in the view? As an argument to
some helper, like maybe h?
in the view. How is the variable used in the view? As an argument to
You are abusing link_to. The syntax for linking to a pregenerated
location is:
<%= link_to ‘Trave’, @link, #the other arguments %>
Otherwise, you generate a route within you controller with @link
as :action parameter.
And parameters will (and have to) be escaped by link generation.
This is really much more of a question for the rails mailing list.
=> "http://www.example.com/logic?
key for each user who is logging in, which becomes park of the link
string and then is passed to the view. However, the CGI.unescape isn’t
working.
So presumably you are building the string without escapes in the
controller. I suspect that it’s getting escaped after that, probably
in the view. How is the variable used in the view? As an argument to
some helper, like maybe h?
I know this has turned out to be a rails like question but the original
question is rooted within the realm of ruby. So far I have tried
CGI.unespace and h method to try and rid a string of characters that
started out as characters but were then converted to hex characters.
The h method (which is an alias for html_escape) does just the
opposite. What I was driving at in my response is that somewhere in
your view code you were doing something like using h which was ADDING
the hex characters.
in the view. How is the variable used in the view? As an argument to
You are abusing link_to. The syntax for linking to a pregenerated
location is:
<%= link_to ‘Trave’, @link, #the other arguments %>
Otherwise, you generate a route within you controller with @link
as :action parameter.
And parameters will (and have to) be escaped by link generation.
This is really much more of a question for the rails mailing list.
Greetins
Florian G.
I know this has turned out to be a rails like question but the original
question is rooted within the realm of ruby. So far I have tried
CGI.unespace and h method to try and rid a string of characters that
started out as characters but were then converted to hex characters.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.