Re: enabling utf8 encoding for sax parer XML::SAX::Expat

Robin Berjon <[email protected]>
Newsgroups gmane.comp.lang.perl.xml
Message-ID <[email protected]>
On Apr 28, 2009, at 18:42 , eyal edri wrote:
> In order to Encode the file to the proper encoding, i'll need to  
> open it 1st and read the 1st line:
>   <?xml version="1.0" encoding="utf-8"?> for e.g.
>
> only then i could run Encode($filename) (not familiar with the  
> syntax yet...) right?
>
> does it mean i need to close the file and reopen it? since i don't  
> really have control on the filehandle (using parse_uri..).

No. You need to know the encoding that the file really is in (which  
has nothing to do with the <?xml?> line). If you don't know what it is  
you could try looking at the file in a hex editor, but that can be  
tedious — it might be best to first try seeing if it converts from  
common encoding mistakes: iso-8859-1, iso-8859-15, and cp-1252.

Once that's done you're probably better off removing the XML  
declaration in case it conflicts.

-- 
Robin Berjon - http://berjon.com/
     Feel like hiring me? Go to http://robineko.com/





_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.