Skeeve has asked for the wisdom of the Perl Monks concerning the following question:
In another forum someone noticed that certain characters, like Umlauts, on OS X are printed like (e.g.) "\334" and asked how to get back the real charcter ("Ü").
My solution to this was a small perl snippet:
This seems to work fine as for examplebinmode STDOUT => ':utf8'; $_= shift; s/([\@\$%:])/\\$1/g; eval qq(print qq:$_:);
correctly prints "Über@nüber.com".deescape '\334ber@n\374ber.com'
But you might have noted the disadvantage: I'm using an "eval" and so might fall for some code injection. I also needed to escape @, $, % and :. The later because I use it as the quote-character.
Currently I have no idea how I could safely get strings like this unescaped.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How can I safely unescape a string.
by tobyink (Canon) on Sep 12, 2012 at 20:43 UTC | |
by davido (Cardinal) on Sep 12, 2012 at 20:56 UTC | |
by remiah (Hermit) on Sep 13, 2012 at 13:30 UTC | |
|
Re: How can I safely unescape a string.
by remiah (Hermit) on Sep 13, 2012 at 12:55 UTC |