slugger415 has asked for the wisdom of the Perl Monks concerning the following question:

Hello, another XML::Twig question. My original files are UTF8 encoded, but after I run my script they are ANSI encoded. Special characters such as German small sharp s ( ß when encoded) still appear in the output, but don't display properly in my XML editor.

I've set keep_encoding, which does save the file in UTF8, but produces some odd character strings and spacing.

Any thoughts on this? thanks as always, Scott

Replies are listed 'Best First'.
Re: XML::Twig and file encoding
by Anonymous Monk on Jul 30, 2014 at 19:05 UTC

      getting an error, maybe I coded something wrong here. (Running on Win7 BTW - should've mentioned.)

      Error open (<:unix) on 'twiggy-WHAT.xml': No such file or directory at C:\working\scripts\ifx-make-conrefs\twiggy.pl line 9.

      my code

      #!/usr/bin/perl -- use Path::Tiny qw/ path /; use Data::Dump qw/ dd /; my $infile = 'twiggy-test.xml'; my $outfile = 'twiggy-WHAT.xml'; dd( path( $infile )->slurp_utf8 ); getTwiggy( $infile , $outfile ); dd( path( $outfile )->slurp_raw ); sub getTwiggy { ## minimal demo of Twig not what you want } __END__

      I do get my XML printed to screen.

      thanks for looking at this.

        You missed the point :) You didn't finish the program :) you did not complete sub getTwiggy which is supposed to create $outfile

        How else would I know what you're doing with XML::Twig and what goes wrong?