Perl Monk, Perl Meditation | |
PerlMonks |
How can I safely unescape a string.by Skeeve (Parson) |
on Sep 12, 2012 at 20:07 UTC ( [id://993301]=perlquestion: print w/replies, xml ) | Need Help?? |
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 example correctly prints "Über@nüber.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. s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{% +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
Back to
Seekers of Perl Wisdom
|
|