On 2016-10-23 11:48, Robert Klemme wrote:
>> I think you can use Kernel#eval to interpret it.
>>
>> irb(main):015:0> str = 'x="legend\\u00e4ren Sinnspr\\u00fcchen
>> verf\\u00fchrte"'
>> => "x=\"legend\\u00e4ren Sinnspr\\u00fcchen verf\\u00fchrte\""
>> irb(main):016:0> eval(str)
>> => "legendren Sinnsprchen verfhrte"
>> irb(main):017:0> x
>> => "legendren Sinnsprchen verfhrte"
>>
>> As you know, eval can be a security hole easily.
> Depends how you use it. In this case, which I believe is a solution to
> the other question, it's not:
>
> irb(main):036:0> x.gsub(/\\u(\h{4})/) {|m| eval "\"\\u#{$1}\""}
> => "legendren Sinnsprchen verfhrte"
>
> Kind regards
>
> robert

Hi,
Thats a nice workaround!
- But can't it be done easier (not emulating the interpolation, like
getting the output which print shows on the screen into a variable?
Sadly print doesn't return what it prints.

Seems there is no method / feature to unset (undef) a 
global/local/class/object - variable?


thanks Opti


Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>