Iñaki Baz Castillo
2/20/2009 4:08:00 PM
El Viernes, 20 de Febrero de 2009, I=C3=B1aki Baz Castillo escribi=C3=B3:
> Hi, I receive a String allowing hexadecimal escaping by using %XX syntax:
>
> %61lice =3D> alice ( %61 =3D=3D a )
>
> I would like to un-escape the string. I've got it using "eval" but I'd
> prefer avoiding using "eval":
>
> string =3D "%61lice"
> string =3D eval %{ "#{ string.gsub(/%/,'\x') }" }
> =3D> "alice"
>
> How could I avoid the usage of "eval" to un-escape the string?
Ops, it is easier than above. CGI lib already does it:
require 'cgi'
CGI.unescape("%61lice")
=3D> "alice"
:)
=2D-=20
I=C3=B1aki Baz Castillo