Hello,

We had been using XML::Writer under Perl 5.6.0 for a while. We are now in the process of upgrading to Perl 5.8.5.

Our source XML documents often contain UTF-8 encoded Unicode characters and we found that XML::Writer in not creating the same characters that it used to. One problem character that we found is — (I understand that there has been significant unicode changes in recent versions of Perl).

Here is what we get (viewed with `less`) after 'converting it to utf-8' from just printing the XML and what the XML::Writer produces:
XML output via 'print': <test><C2><97></test> XML output via XML::Writer: <test><97></test>

The 'solution' we came up with was to add:

  binmode($FILE_HANDLE, ":encoding(utf-8)");

to the Writer.pm just after it picks up the file handle like:

# Set the output. if ($params{'OUTPUT'}) {binmode ($params{'OUTPUT'}, ":encoding(utf +-8)"); } &{$self->{'SETOUTPUT'}}($params{'OUTPUT'});

So, is this a valid fix or is it going to give us additional problems later on? If this is a valid patch can someone explain why?

Thanks,
josh

In reply to problem with XML::Writer, unicode and Perl 5.6.0 upgrade by santellij

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.