Hi all, is there any way how to simplify this function:
sub h_escapes { my ($index, $char, $output); for($index=0; $index<length($_[0]); $index++) { $char = ord(substr($_[0], $index, 1)); if($char < 0x20 || $char > 0x7f) { $output = $output . sprintf("\\x%02x", $char); } else { $output = $output . substr($_[0], $index, 1); } } return $output; } It converts 'non-printable' characters in string to ansi hex escapes (\xxx) and returns new string. Maybe there is some standard function for this purpose, which I missed. Or maybe with regular expression it's possible to do it as one-liner. Any hints? Regards, R. Wajda