in reply to How to replace extended ascii ctrs with \xnn strings?
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 | |
|
Re^2: How to replace extended ascii ctrs with \xnn strings?
by bulrush (Scribe) on Dec 14, 2015 at 18:01 UTC |