Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
To start with an overview: I have a big file of Western-encoded messages, you could call it some sorta non-standard blog, marked-up with HTML. Am now trying to clean up things, storing the messages as XML (more specific: as RSS 2.0), and displaying them as HTML. The encoding should change to UTF-8.
Most of the things work, just the UTF-8 encoding of special entities for the XML drives me nuts. I have been deploying the XML::RSS Perl module, which might or might not be a good idea afterOverview: I have a big file of Western-encoded messages, you could call it some sorta non-standard blog, marked-up with HTML. Am now trying to clean up things, storing the messages as XML (more specific: as RSS 2.0), and displaying them as HTML. The encoding should change to UTF-8.
Most of the things work, just the UTF-8 encoding of special entities for the XML drives me nuts. I have been deploying the XML::RSS Perl module, which might or might not be a good idea after testing it. E.g. sometimes the encode_output switch is being ignored depending on which server I execute the script.
It also seems XML::RSS does not correctly support the common way of encoding/decoding UTF-8 entities. In those cases where the mentioned "encode_output" of XML::RSS does work it produces something like this for the lower-case 'a' with two dots on top: testing it. E.g. sometimes the encode_output switch is being ignored depending on which server I execute the script.
It also seems XML::RSS does not correctly support the common way of encoding/decoding UTF-8 entities. In those cases where the mentioned "encode_output" of XML::RSS does work it produces something like this for the lower-case 'a' with two dots on top:
ä
When XML::RSS reads in entities like this it gets correctly decoded. But some common RSS readers are not swallowing it. It _seems_ that the encoding for the above example should have been:
쎤
When XML::RSS reads entities like this, something goes wrong and I see funny characters as result. After some frustration I had written the encoding myself like the second version, which solves the encoding part but XML::RSS does not like it.
- My questions are:
- Are both ways above correct when encoding UTF-8 in XML?
- Is using XML::RSS a bad idea? Any alternatives?
- How to best encode those entities in HTML for output?
- Side topic: Could it be that RSS readers better support decimal encoding, e.g. 쎤 than the hexadecimal equivalent 쎤 ?
Would be really glad if someone could help with any part of it
Jot
20080909 Janitored by Corion: Added closing list tag, as per Writeup Formatting Tips
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: UTF-8 entities in XML/HTML?
by moritz (Cardinal) on Sep 03, 2008 at 14:00 UTC | |
by Anonymous Monk on Sep 03, 2008 at 15:37 UTC | |
Re: UTF-8 entities in XML/HTML?
by pat_mc (Pilgrim) on Sep 03, 2008 at 15:08 UTC | |
by Anonymous Monk on Sep 03, 2008 at 16:01 UTC | |
by pat_mc (Pilgrim) on Sep 04, 2008 at 16:29 UTC | |
Re: UTF-8 entities in XML/HTML?
by Juerd (Abbot) on Sep 03, 2008 at 13:55 UTC |