Hi all
I'm having problems using XML::Simple to parse a data file containing the '£' symbol.

The data appears to read in correctly without error, but when I come to output it, the symbol appears as '£'.

Trawling as much documentation as I could find, SuperSearching and googling it looks like this is a problem with the encoding - the XML::Parser transforms everything to UTF-8 internally which can't handle '£' correctly. If I understand correctly it performs a bit shift that changes it into the 2-byte char that gets output.

The problem I have is how to get the correct symbol back when I read the data back out.

I've tried playing with the various encoding options of XML::Simple (and I've tried XML::DOM also) but to no avail. Maybe I'm missing something obvious by staring at it too hard.

Any help would be greatly appreciated :)

Update

Thanks for all the helpful advice everyone! I think I have a few possible solutions now to the problem (which I'll have to find which will work best under the system / network architecture that we have here) which is a lot more than the "none" that I had when I started :)

You've saved me a lot of torn out hair :)

--- Jay

All code is untested unless otherwise stated.
All opinions expressed are my own and are intended as guidance, not gospel; please treat what I say as such and as Abigail said Think for yourself.
If in doubt ask.

s++blah+;y(bl) .j.s;s+(h)+p$1+;???print:??;


In reply to Problem reading £ sign with XML::Simple by gothic_mallard

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.