Re: enabling utf8 encoding for sax parer XML::SAX::Expat
eyal edri <[email protected]>
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <[email protected]> |
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. > you meaning running Encode on the file before opening it? , assuming i'll know it's UTF-8 (look at the response headers for e.g.). > > -- > 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