[xml] Perl module XML::LibXML not encoding UTF-8 properly

Could someone please explain why the following perl script fails?




Loren Osborn

Software Engineer

Dispensing Solutions Inc

(714) 437-0330





use XML::LibXML;


my $sValue = "Una manzana al d\xEDa mantiene al doctor ausente.";

print "This is the input string:\n\t$sValue\n";

my $rNewTextNode = XML::LibXML::Text->new($sValue);

my $sOutput = $rNewTextNode->toString();

print "When XML::LibXML encodes this as a XML::LibXML::Text node we get:\n\t".




if($sOutput =~ /\&\#x0*[Ee][Dd];a / ) {

  print "This looks RIGHT! :)\n";

} else {

  $sOutput =~ s/\&\#x[0-9a-fA-F]+;/\&\#xED;a /;

  print "THIS IS WRONG!  This SHOULD be:\n\t$sOutput\n";


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]