It seems the printToFile method has not been written with unicode in mind1... but you could create a properly UTF-8-encoding file handle yourself, and then either use ->printToFileHandle, or simply ->print
... open my $fh, ">:utf8", "accentTestOutPut.xml" or die $!; # Print doc file $doc->printToFileHandle($fh); # or $doc->print($fh);
$ hexdump -C accentTestOutPut.xml 00000000 3c 3f 78 6d 6c 20 76 65 72 73 69 6f 6e 3d 22 31 |<?xml ver +sion="1| 00000010 2e 30 22 20 65 6e 63 6f 64 69 6e 67 3d 22 55 54 |.0" encod +ing="UT| 00000020 46 2d 38 22 3f 3e 0a 3c 54 45 53 54 3e 20 c3 a9 |F-8"?>.<T +EST> ..| 00000030 20 3c 2f 54 45 53 54 3e 0a | </TEST>. +| ^^^^^
___
1 current implementation:
sub printToFile { my ($self, $fileName) = @_; my $fh = new FileHandle ($fileName, "w") || croak "printToFile - can't open output file $fileName"; $self->print ($fh); $fh->close; }
In reply to Re: XML:: DOM and Accented Characters
by almut
in thread XML:: DOM and Accented Characters
by freeflyer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |