in reply to Re^2: Problem reading £ sign with XML::Simple
in thread Problem reading £ sign with XML::Simple

You have to understand what's going on here:

The XML declaration tells the parser in which encoding the input document is encoded. In your case it's probably either ISO-8859-1 (or ISO-8859-15 if you use the € sign) or one of the windows encodings (I can't remember what the names are). So you need the proper declaration for the parser to be able to parse the data, and to make sense of it.

Then XML::Simple (actually the parser underneath it) converts everything to UTF-8. That's the usual way, so your code (and the parser's) doesn't have to behave differently depending on the input encoding.

Then you want to output the document in a given encoding, in your case probably the same as the input encoding. This is the step that you are missing.

With 5.6.1 (which, as mentionned earlier you should really update to 5.8.6) you have to use either Text::Iconv or Unicode::Map8 / Unicode::Strings. A SuperSearch on "character encoding conversion" or "utf8 iso-8859-1" or something like that should give you plenty of ways to do this.

And of course XML::Twig will let you work with the same encoding as the input ;--)

  • Comment on Re^3: Problem reading £ sign with XML::Simple