Ticket #125: unicode_input_for_text_template-r611.diff
| File unicode_input_for_text_template-r611.diff, 1.3 KB (added by cboos, 16 years ago) |
|---|
-
genshi/template/tests/text.py
54 54 tmpl = TextTemplate(text, encoding='iso-8859-1') 55 55 self.assertEqual(u'x\xf6y', unicode(tmpl.generate(foo='x', bar='y'))) 56 56 57 def test_unicode_input(self): 58 text = u'$foo\xf6$bar' 59 tmpl = TextTemplate(text) 60 self.assertEqual(u'x\xf6y', unicode(tmpl.generate(foo='x', bar='y'))) 61 57 62 def test_empty_lines1(self): 58 63 tmpl = TextTemplate("""Your items: 59 64 -
genshi/template/text.py
64 64 stream = [] # list of events of the "compiled" template 65 65 dirmap = {} # temporary mapping of directives to elements 66 66 depth = 0 67 if not encoding:68 encoding = 'utf-8'69 67 70 source = source.read().decode(encoding, 'replace') 68 source = source.read() 69 if isinstance(source, str): 70 source = source.decode(encoding or 'utf-8', 'replace') 71 71 offset = 0 72 72 lineno = 1 73 73
