The problem is that 0xFF is in the extended character set and is being passed straight through to the file. Without knowing your encoding, you don't know what character it is supposed to be. This is the problem that Unicode is supposed to solve, but it does it with a careful encoding mechanism, and your 0xFF appearing raw in a file that is supposed to be Unicode is invalid Unicode, and so you get an error.
I'm not sure what the best API is for solving it, but you can solve it as follows if you have a recent enough Perl (I know that Perl 5.8 works, I dunno how bad Perl 5.6 is in this respect). If your XML file is called, say, "output.xml", then open it with, IO::File->new(">:utf8", "output.xml") and leave the rest of your code alone. (I may have that open command wrong, if I did then stare at documentation and play with it until you figure out how to convince Perl to automatically output correct Unicode.)
I won't guarantee, however, that the author of XML::Writer won't some day decide to solve the Unicode problem on his end, leading to a double-encoding and garbage output. Contacting him may therefore be worthwhile.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.