I'm afraid I don't understand what the problem is, exactly. Your three examples are all identical chunks of code (except for an apparent copy/paste error in the second one: you left out the initial "<?" in the first line of the HEREDOC (in front of "xml").
Aside from being identical (so there should be no difference at all in the outputs), none of the examples seem to involve any wide (non-ASCII) characters. Since the 128-element ASCII table is a proper subset of both cp1252 and utf8, I would expect that there really is no difference at all in the three outputs -- they are all just plain, simple ASCII.
There is no discernable difference between utf8 and cp1252 (or iso-8859-*, or even Asian character sets like GBK or Big5) when you're only looking at data that consists entirely of ASCII characters -- all those encodings handle ASCII the same way.
Have you tried to output any data with non-ASCII characters? (which ones, if any?) Show us an example of the code you use to do that, and try to make it clear for us:
- Where do the wide characters come from? (Hard-coded in the perl script? Read from some external source?)
- What exactly shows up in the output file as a result?
(A hex dump of the file contents would be handy, though sometimes the problem can be obvious based on how the text appears in a common Latin1 or utf8 display environment.)
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.