The encoding of the document is specified in the document, not externally (e.g. the system's locale or an HTTP header). Determining the encoding requires parsing the document, so it's up to the XML parser to do the decoding. This is why XML is considered a binary (application/) format, not a text (text/) format.

If it was up to the caller to decode the content as you claim, the caller would have to parse the XML to determine the encoding before passing the XML to the parser. That's what makes no sense.

yet to solve a problem with it not being interpreted properly as UTF-8 text by a module

That's not true. It is expected to be UTF-8 by the module and treated as such. The problem is that by decoding the text, you're passing text that's not encoded using UTF-8 anymore.


In reply to Re^4: Encode throws "Wide character in subroutine entry" when using XML::Simple by ikegami
in thread Encode throws "Wide character in subroutine entry" when using XML::Simple by nglenn

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.