If you don't know what encoding the character data is in, it isn't very useful. You might as well strip it out completely because without figuring out the encoding, it is just junk. You may be able to puzzle out the encoding by looking at the characters. For European languages, it is probably ISO-8815-1, might have Windows CP1252 characters in it.

Many of the 8-bit encoding can be translated to Unicode and back again without loosing any information. You will need to choose an encoding that works well for this; Latin1 or CP1252 are reasonable choices. There are two ways to handle this in XML. The best way is probably write the XML in your encoding and tag it.

XML::Writer looks like it doesn't do any translation. You will need to write the chosen encoding, make sure the file is in binary mode, and write the strings. The parsers that XML::Simple support encodings on the file. But they need to know about the encoding because they translate everything into Unicode character data. Which are stored in Perl in UTF-8 and will need to be translated to your "safe" encoding after reading.


In reply to Re: 8-bit Clean XML Data I/O? by iburrell
in thread 8-bit Clean XML Data I/O? by samtregar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.