Andrew Veitch wrote at 2006-3-20 01:53 +0000:
... <input name="blah" type="text" tal:attributes="value python:chr (200).encode('utf-8')" /> This gives:
Error Type: UnicodeDecodeError Error Value: 'ascii' codec can't decode byte 0x80 in position 0: ordinal not in range(128)
Sure, you are using "str.encode" in a wrong way: "str.encode('uft-8')" is equivalent to "unicode(str, getdefaultencoding()).encode('utf-8')". What encoding should your "200" use? Convert it to unicode using this encoding (and let the ZPublisher convert the unicode to "utf-8"). By the way, your exception must come from somewhere else as "chr(200)" cannot lead to a "byte 0x80". It is always worth to look at the traceback. It tells you where the exception really comes from...
... <input name="blah" type="text" tal:attributes="value python:chr(200)" />
Then this will work in HTML mode but will fail in XML mode.
You should use Unicode in XML mode...
...
I could provide patches, if useful.
I would be very interested to see you patches.
Attached. -- Dieter