Reputation: 1705
I have a test string like :
my $input = "testing &test ₨";
my $output = HTML::Entities::encode_entities($str,"<>&\"'");
The desired output is
testing &test ₨
But HTML::Entities::encode_entities is encoding this into
testing &test &#8360;
To summarize, I want the HTML::Entities to encode the "&" character only if it does not represent an HTML entity number.
Upvotes: 0
Views: 549
Reputation: 4038
You need to decode the string first, then encode it:
#!/usr/bin/env perl
use strict; use warnings; use v5.10;
use HTML::Entities ();
my $input = "testing &test ₨";
$input = HTML::Entities::encode( HTML::Entities::decode( $input ) );
say $input;
The result is
testing &test ₨
20A8
is the hexadecimal version of 8360
.
Upvotes: 7