#! /usr/bin/perl -p

##############################################################################
#
# PURPOSE
#
# Finds non-ASCII octets and converts them to ASCII printed hexidecimal
# representations.
#
# USAGE
# 
# Standard Unix filter.
#
# LEGAL
#
# This program was placed in the public domain on 1 Jan 2002.
# This program has NO WARANTY.  USE IT STRICTLY AT YOUR OWN RISK.
#
##############################################################################

# convert to text representation (hexidecimal base) of ordinal value
# match pattern is character class of non-printable characters
while (m/([\x00-\x08\x10-\x1F\x7E-\xFF])/) {
	$char = $1;
	$val = unpack ('C', $char);		# ordinal value
	$str = sprintf ("[0x%X]", $val);	# hex with 0x prefix
	s/$char/$str/g;
}

# END OF FILE
