#!/bin/perl -w
use XML::DOM;
my $parser = new XML::DOM::Parser;
my $doc = $parser->parsefile ("c:\\accentTest.xml", ProtocolEncoding => 'UTF-8');
# Print doc file
$doc->printToFile ("c:\\accentTestOutPut.xml");
#re-open file in UTF-8 encoded filehandle
open my $fh, ">:utf8", "accentTestOutPut.xml" or die $!;
$doc->print($fh);
# cleanup
$doc->dispose;
####
#!/bin/perl -w
use XML::DOM;
my $parser = new XML::DOM::Parser;
my $doc = $parser->parsefile ("c:\\accentTest.xml", ProtocolEncoding => 'UTF-8');
# Print doc file
$doc->printToFile ("c:\\accentTestOutPut.xml");
#re-open file in UTF-8 encoded filehandle
open my $fh, ">:utf8", "accentTestOutPut.xml" or die $!;
print $fh "\x{FEFF}"; # BOM
$doc->print($fh);
# cleanup
$doc->dispose;
####
#!/bin/perl -w
use XML::DOM;
use UTF8BOM;
my $parser = new XML::DOM::Parser;
my $doc = $parser->parsefile ("c:\\accentTest.xml", ProtocolEncoding => 'UTF-8');
# Print doc file
$doc->printToFile ("c:\\accentTestOutPut.xml");
UTF8BOM->insert_into_file('c:\\accentTestOutPut.xml');
# cleanup
$doc->dispose;
####
#!/bin/perl -w
use XML::DOM;
use Encode qw(encode_utf8);
my $parser = new XML::DOM::Parser;
my $doc = $parser->parsefile ("c:\\accentTest.xml", ProtocolEncoding => 'UTF-8');
# Print doc file
$doc->printToFile ("c:\\accentTestOutPut.xml");
open my $fh, ">:utf8", "accentTestOutPut.xml" or die $!;
encode_utf8($fh);
$doc->print($fh);
# cleanup
$doc->dispose;
####
#!/bin/perl -w
use XML::DOM;
use PerlIO::encoding;
my $parser = new XML::DOM::Parser;
my $doc = $parser->parsefile ("c:\\accentTest.xml", ProtocolEncoding => 'UTF-8');
# Print doc file
$doc->printToFile ("c:\\accentTestOutPut.xml");
open my $fh, ">:encoding(UTF-8)", "accentTestOutPut.xml" or die $!;
$doc->print($fh);
# cleanup
$doc->dispose;