sub XML::Writer::_escapeLiteral { # escape 'normal' characters e.g. ampersand if ($_[0] =~ /[<>&"']/) { $_[0] =~ s/\&/&/g; # ampersand $_[0] =~ s/\"/"/g; # quotes $_[0] =~ s/\/>/g; # right angle $_[0] =~ s/\'/'/g; # apostrophe # Add more here... } # Look for occurrances of chars in the range outside normal 7 bit ascii table # Note the character in Octal if ($_[0] =~ /([\177-\377])/) { my $escapedString = ""; # Generic escape for all other chars while ($_[0] =~ /\G(.*?)([\177-\377])/gc) { # concat the escaped char in the form { $escapedString .= sprintf ("%s&#%d;", $1, ord($2)); #print "escapedstring = $1 \n"; } # Concat whatever is left if ($_[0] =~ /\G(.*)$/g) { $escapedString .= $1; } return $escapedString; } return $_[0]; }