Public
Authored by Thimo Kraemer

Zope: Mix unicode and non-latin1 characters in DTML

When Unicode strings are mixed with plain strings in DTML, the plain string is converted to unicode assuming that it contains latin-1 characters (see http://www.zope.org/Members/htrd/howto/unicode). That behaviour fails on utf-8 encoded strings with a UnicodeError.

But we could convert plain strings from utf-8 first and fall back to latin-1 only on error. This gives the ability to support at least two common used encodings.

So here is the workaround: The following monkeypatch of DT_Util.py modifies the method string.join, which is used by cDocumentTemplate.c later on.

DT_Util.diff 1.17 KB
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment