Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Problem upgrading XML::Fast from 0.11 to 0.17

by ablanke (Vicar)
on Sep 22, 2017 at 19:26 UTC ( #1199930=note: print w/replies, xml ) Need Help??


in reply to Re: Problem upgrading XML::Fast from 0.11 to 0.17
in thread Problem upgrading XML::Fast from 0.11 to 0.17

Hi,
It is the parser's job to handle decoding.

To do so, the parser needs to know the encoding of the XML.

The XML declaration (<?xml version="1.0" encoding="ISO-8859-1"?>) does provide that information for the parser.

$xml =~ s/^(?:.*\n)//;    # remove first line - the encoding line

By removing the XML declaration the Parser seems to guess the (wrong) source encoding. uses the default encoding.*

With XML declaration your code seems to work correctly. Please notice that XML::Fast upgrades the data to utf8. But now in the correct manner.

*updated

Replies are listed 'Best First'.
Re^3: Problem upgrading XML::Fast from 0.11 to 0.17
by ikegami (Pope) on Sep 23, 2017 at 04:02 UTC

    By removing the XML declaration the Parser seems to guess the (wrong) source encoding.

    There's no guessing involved. If there's no encoding specified, then it must be UTF-8 to be valid XML.

Re^3: Problem upgrading XML::Fast from 0.11 to 0.17
by mje (Curate) on Sep 25, 2017 at 11:55 UTC

    See my reply to ikegami. I was opening the file with ISO-8859-1 and removing the XML encoding line because of previous bugs in XML::Fast.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1199930]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2020-05-26 13:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (150 votes). Check out past polls.

    Notices?