# subroutine name: safe_tag
# HTML-encodes string (prepare data for HTML output)
# Replaces:
# & -> &
# < -> <
# > -> >
# " -> "
# \x0D -> remove
sub safe_tag {
my ($input) = @_;
$input =~ s/&/&/sg;
$input =~ s/\</sg;
$input =~ s/\>/>/sg;
$input =~ s/\"/"/sg;
$input =~ s/\x0D//sg;
$input=~s/([\x01-\x08\x0B-\x1F])/"".ord($1).";"/esg;
$input;
}