diff --git a/CHANGES.txt b/CHANGES.txt index ae982e1..4956da5 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,7 @@ Changelog 2.13.5 (unreleased) ------------------- +- Use 'utf-8' to decode non-unicode strings instead of 'latin-1'. 2.13.4 (2017-02-15) ------------------- diff --git a/src/DocumentTemplate/cDocumentTemplate.c b/src/DocumentTemplate/cDocumentTemplate.c index 47ae784..1800ce2 100644 --- a/src/DocumentTemplate/cDocumentTemplate.c +++ b/src/DocumentTemplate/cDocumentTemplate.c @@ -925,7 +925,7 @@ _join_unicode(PyObject *prejoin) PyObject *item = PyList_GetItem(list,i); if(PyString_Check(item)) { - PyObject *unicode = PyUnicode_DecodeLatin1(PyString_AsString(item),PyString_Size(item),NULL); + PyObject *unicode = PyUnicode_DecodeUTF8(PyString_AsString(item),PyString_Size(item),NULL); if(unicode) { PyList_SetItem(list,i,unicode); diff --git a/src/DocumentTemplate/tests/testDTMLUnicode.py b/src/DocumentTemplate/tests/testDTMLUnicode.py index 1d98bc4..659a859 100644 --- a/src/DocumentTemplate/tests/testDTMLUnicode.py +++ b/src/DocumentTemplate/tests/testDTMLUnicode.py @@ -55,25 +55,25 @@ def testAB(self): def testUB(self): html=self.doc_class('') expected = u'hello\xc8' - res = html(a=u'hello',b=chr(200)) + res = html(a=u'hello',b='\xc3\x88') assert res == expected, `res` def testUB2(self): html=self.doc_class('') expected = u'\u07d0\xc8' - res = html(a=unichr(2000),b=chr(200)) + res = html(a=unichr(2000),b='\xc3\x88') assert res == expected, `res` def testUnicodeStr(self): html=self.doc_class('') expected = u'\u07d0\xc8' - res = html(a=force_str(unichr(2000)),b=chr(200)) + res = html(a=force_str(unichr(2000)),b='\xc3\x88') assert res == expected, `res` def testUqB(self): html=self.doc_class('') expected = u'he>llo\xc8' - res = html(a=u'he>llo',b=chr(200)) + res = html(a=u'he>llo',b='\xc3\x88') assert res == expected, `res` def testSize(self):