Re: PingTool.py converts 8 bit characters into entities
Georg Bauer <gb-BRhJDZTO+/[email protected]> Wed, 17 Mar 2004 12:09:11 +0100
| Newsgroups | gmane.comp.pythin.pyds.devel |
|---|---|
| Message-ID | <r02010100-1028-8580FFEF780311D8A517000A9573A72A@[10.0.0.145]> |
Hi! > So what they do: they decode the entity encoded &#XXX; to their > ISO-8859-1 encoding and store that in their database. They return the > decoded entity as a ISO-8859-1 character - without declaring their > charset in the XML header! So I have commited a fix for this problem. Ok, not a fix, as the duty to produce that one belongs to Userland, but at least some workaround in PyDS. I use mostly the same heuristic as in PyCS: - try to parse the response with expat directly (using whatever header and encoding is used in the response) - if that works, fine, we have a result - if it breaks, replace <?xml version="1.0"?> with <?xml version="1.0" encoding="iso-8859-1"?> in the response and parse again with expat - if that works, fine, we now have a result - if it breaks, produce an exception So this should work with normal XMLRPC implementations, as they usually just work fine with UTF-8 and support encodings as should be. In the case of weblogs.com, it will work too - it just needs to parse the stuff twice, sometimes. This is an ugly hack. But at least it works now. Kind of. bye, Georg