Typist
view release on metacpan or search on metacpan
lib/Typist/Util/String.pm view on Meta::CPAN
'"' => '"',
'<' => '<',
'>' => '>',
'\'' => '''
);
my %Map_Decode = reverse %Map;
my $RE = join '|', keys %Map;
my $RE_D = join '|', keys %Map_Decode;
sub encode_xml {
my ($str, $nocdata) = @_;
return '' unless defined $str;
if (
!$nocdata
&& $str =~ m/
<[^>]+> ## HTML markup
| ## or
&(?:(?!(\#([0-9]+)|\#x([0-9a-fA-F]+))).*?);
## something that looks like an HTML entity.
/x
) {
## If ]]> exists in the string, encode the > to >.
$str =~ s/]]>/]]>/g;
$str = '<![CDATA[' . $str . ']]>';
( run in 0.739 second using v1.01-cache-2.11-cpan-454fe037f31 )