On 03/08/12 12:42, Oldrich Kruza via RT wrote:
Show quoted text> use XML::Entities;
> use HTML::Entities;
> %HTML::Entities::char2entity = %{
> XML::Entities::Data::char2entity('all');
> };
> my $encoded = encode_entities('tom&jerry');
> # now $encoded is 'tom&jerry'
Thanks. That's getting close, but I have a scenario which reads HTML
data and wants to send it as XML as demonstrated by this code:
#!/usr/bin/perl -wT
use XML::Entities;
use HTML::Entities;
my $string = 'PROVENCE-ALPES-CÔTE d\'AZUR';
$string = decode_entities($string);
%HTML::Entities::char2entity = %{
XML::Entities::Data::char2entity('all');
};
print encode_entities($string), "\n";
This outputs as
PROVENCE-ALPES-CÔTE d'AZUR
Which I believe is not valid XML. I believe what I want is:
PROVENCE-ALPES-C&O#212;TE d‚AZUR
Am I right? I admit I'm unsure on this.