Forum: Ruby unescape result from inspect

97334b75c93574ed3e514f33849f0953?d=identicon&s=25 Mario Ruiz (tcblues)
on 2013-10-18 16:15
how can i unescape the results from inspect method. I tried with URI but
not lucky :(

x={"a"=>"aaaaaaaaaaaaaa","b"=>"ññññækkksdlæp@"}
puts URI.unescape(x.inspect)
E0d864d9677f3c1482a20152b7cac0e2?d=identicon&s=25 Robert Klemme (robert_k78)
on 2013-10-18 17:20
(Received via mailing list)
On Fri, Oct 18, 2013 at 4:15 PM, Mario Ruiz <lists@ruby-forum.com>
wrote:
> how can i unescape the results from inspect method. I tried with URI but
> not lucky :(
>
> x={"a"=>"aaaaaaaaaaaaaa","b"=>"kkksdlp@"}
> puts URI.unescape(x.inspect)

Why do you expect that to work at all?  URI escaping != #inspect format.

Cheers

robert
97334b75c93574ed3e514f33849f0953?d=identicon&s=25 Mario Ruiz (tcblues)
on 2013-10-18 17:21
So.... no possible to be unescaped?

Robert Klemme wrote in post #1124848:
> On Fri, Oct 18, 2013 at 4:15 PM, Mario Ruiz <lists@ruby-forum.com>
> wrote:
97334b75c93574ed3e514f33849f0953?d=identicon&s=25 Mario Ruiz (tcblues)
on 2013-10-29 17:06
The problem is I have values escaped with inspect stored on Database and
later on I need to recover them and unescape them to be used... any
idea?
E0d864d9677f3c1482a20152b7cac0e2?d=identicon&s=25 Robert Klemme (robert_k78)
on 2013-10-29 17:44
(Received via mailing list)
On Tue, Oct 29, 2013 at 5:06 PM, Mario Ruiz <lists@ruby-forum.com>
wrote:
> The problem is I have values escaped with inspect stored on Database and
> later on I need to recover them and unescape them to be used... any
> idea?

The approach is broken: #inspect's format is not intended for
serialization.  You need to use a different mechanism to serialize
your objects into and out of the database:

 - Marshal (binary)
 - YAML (text)
 - some form of XML serialization
 - some form of JSON serialization

Cheers

robert
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.