in reply to Re^3: Transform ASCII into UniCode (escape_metas)
in thread Transform ASCII into UniCode
I wanted to have a generic method for escaping selected metas while keeping others as is.
> what did I do wrong?
Took me a moment to understand (well guess) what's happening
Take case #2:
a\\b is internally the 3 char string a\b , so this escape b is untouched.
but you do a string interpolation for
eval "\$string =~ tr/$s/$r/r"
so whats happening is
DB<57> say "a\\b" =~ tr/a\b/xyz/r # expected 'xyz' x\b DB<58>
Actually I'm not sure what tr's interpretation of \b is here
Question is if your expectation was right, because the literal code gives my result (?)
C:\tmp\t_wperl>perl -E"say 'a\\b' =~ tr/a\b/xyz/r # expected 'xyz'" x\b C:\tmp\t_wperl>
I.o.W.
Your expectation is to have a 1-to-1 mapping of characters.
My expectation was to emulate tr like implemented and to catch injections.
It's a question of definition.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Transform ASCII into UniCode (escape_metas)
by LanX (Saint) on Mar 23, 2021 at 19:08 UTC | |
by choroba (Cardinal) on Mar 23, 2021 at 19:52 UTC | |
by LanX (Saint) on Mar 23, 2021 at 21:06 UTC | |
by LanX (Saint) on Mar 23, 2021 at 23:27 UTC |