in reply to How to replace extended ascii ctrs with \xnn strings?

I think if you replace 122 below with 127, it will work. I just used 122 to demonstrate with printable characters:
use warnings; use strict; my $s = 'foo bar {}{}'; $s =~ s/(.)/(ord($1) > 122) ? sprintf '\\x%x', ord($1) : $1/ge; print "$s\n"; __END__ foo bar \x7b\x7d\x7b\x7d

Replies are listed 'Best First'.
Re^2: How to replace extended ascii ctrs with \xnn strings?
by bulrush (Scribe) on Dec 14, 2015 at 18:24 UTC
    Wow, it works great. There were all kinds of hidden extended characters that I wasn't removing, no wonder it looked like shite! :) I'm filing this in my regex notes.
Re^2: How to replace extended ascii ctrs with \xnn strings?
by bulrush (Scribe) on Dec 14, 2015 at 18:01 UTC
    Thank you! I will try the 2 examples I saw in a bit. Yes there could be multiple extended ascii characters in a given string.