#!/bin/perl -w
 use strict;
 use XML::Parser;
 use XML::Encoding;
 my $p= new XML::Parser( Handlers =>
                          { Start   => \&default,
                            End     => \&default,
                            Default => \&default,
                            XMLDecl => sub { decl( "UTF-8", @_); }
                          },
                       );
 $p->parsefile($ARGV[0]);
 exit;

 # update the encoding
 sub decl
   { my( $new_encoding, $p, $version, $encoding, $standalone)=@_;
     print "<?xml version=\"$version\" encoding=\"$new_encoding\"";
     print "standalone=\"$standalone\"" if( $standalone);
     print "?>\n";
   }

 # by default print the UTF-8 encoded string received from the parser
 sub default
   { my $p= shift;
     my $string= $p->recognized_string();    
     print $string;
   }
