in reply to Unmangle RSS encodings
I'd tend to say that you can do something quite simple: If your XML parser refuses to parse it, throw it out. That's how XML is supposed to work. OTOH, a quick glance at that URL in mozilla does not give a parse error, so it must not be invalid XML. (Note that it being invalid utf8 would automatically make it invalid XML.)
At this point, you have two choices, both valid, on what to do about it. You can either display it just like it says to display it: AÂÂ’s and all -- which is what the feed tells you to do -- or you can try and make it look more or less like what it's supposed to be.
If you want to do the later, try this: Your XML parser should already decode the "outer" (XML) layer of the double-encoding, and give you AÂÂ’s. Run a simple m/&\w+;/ against it. If that matches, it's probably been HTML-encoded before being XML-encoded. Run it though HTML::Entities to HTML-decode it.
Note that this will get it down to "A&ÂÂ’s", which may or may not have been what they originally intended (I suspect they meant to say A&Â's, and the extra  came from somewhere completely random). It is, however, as close as you can reasonably get.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Unmangle RSS encodings
by qq (Hermit) on Jul 01, 2004 at 05:00 UTC |