in reply to hex in regexp
If you can be sure that all non-ASCII characters fit in 8 bits (in whatever codepage that hopefully you and the receiver agree upon) the suggestions so far are fine. Otherwise I'd use this, adding a "%U" before each hex sequence to make it (better, though not perfectly unless you escape existing percent signs too) distinguishable from something like "face" or "decade" that's only valid hex digits:
perl -Mutf8 -Mstrict -Mwarnings -E ' my $x = "\x966\x959\x959\x946\x945\x961"; # Greek "foobar" $x =~ s/([[:^ascii:]])/sprintf("%%U%x", unpack q{U}, $1)/eg; say $x; '
|
|---|