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

eyal edri <[email protected]>
Newsgroups gmane.comp.lang.perl.xml
Message-ID <[email protected]>
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..).



On Tue, Apr 28, 2009 at 6:36 PM, Robin Berjon <[email protected]> wrote:

> On Apr 28, 2009, at 13:41 , eyal edri wrote:
>
>>        • how can i tell the parser to open the xml in a certain encoding
>> (despite the sender fucked up and didn't add the magic numbers) ?
>>
>
> As Michael explained, it's not so much about magic numbers (unless you're
> in UTF-16 and the encoding isn't declared, but that really is orthogonal).
> If you want to parse a file, it really has to be in the right encoding in
> its entirety.
>
> If you're getting XML documents that are in encoding X and don't declare
> so, then I'd recommend using the Encode module to convert them from X to
> UTF-8, and then parse that without telling the parser anything specific.
>
> --
> Robin Berjon - http://berjon.com/
>    Feel like hiring me? Go to http://robineko.com/
>
>
>
>
>
>


-- 
Eyal Edri

_______________________________________________
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.