[Zope3-dev] Re: zope.tal.xmlparser.XMLParser() dislikes unicode

Andreas Jung lists at zopyx.com
Mon Jan 15 15:49:43 EST 2007



--On 15. Januar 2007 15:44:01 +0100 Martijn Faassen 
<faassen at startifact.com> wrote:

> Hey,
>
> On 1/15/07, Andreas Jung <lists at zopyx.com> wrote:
> [snip]
>> ok, got it. But this problem can be solved easily by changing the
>> encoding within the preamble.
>
> I would say refusing to guess and bailing out with an error message is
> better in this case. The Zen of Python:
>
> In the face of ambiguity, refuse the temptation to guess.
>

Sorry but I don't get your point. What's happening with a XML inside a ZPT?

 - XML data encoded as XXX comes in (either by editing the XML file through
   the ZMI or FTP/WebDAV upload)

 - ZPT converts the encoded string to unicode based on the encoding in the 
preamble

 - for parsing it is up to the application to decide what to do with the 
data. It is not up to the editor to decide how the ZPT engine should deal 
with XML internally. The ZPT engine decides to serializes the unicode 
string as utf-8 and to fix the XML preamble (which will result in a valid 
XML file
which should identical with the original file - except the encoding might 
be different).

I still don't see what should ambiguous with this approach.

Andrea
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope3-dev/attachments/20070115/3c6f6872/attachment.bin


More information about the Zope3-dev mailing list