encoding problem
Juan Fiol <[email protected]> Tue, 24 Nov 2009 18:51:29 -0800 (PST)
| Newsgroups | gmane.comp.python.cheetah |
|---|---|
| Message-ID | <[email protected]> |
Hi, using versions 2.2.2 and 2.4.0 in gentoo I found that previous working templates (with version 2.0.1) do not longer work. The error point out to encoding (ascii not being good for some chars). After posting to tahchee mail list, I included encoding directives like suggested in the manual:
#encoding: UTF-8
but they were not recognized. It finally seems that I could identify the problem to the file Compiler.py. The line looking for the encoding is using re.match rather than re.search
I would think that re.match should work but in fact it does not.
I corrected the problem in my system by applying the simple patch that is included at the end. Is it correct? Or the problem shows from some other issue that I am not seeing?
Another question: The behavior of cheetah has changed from version 2.0.1 . Previously I did not have any encoding defined and it just worked. Now I have to include a line with the encoding in each file to make it work. Is there another way to do it (like defining a global encoding)?
Cheers, Juan
Info:
Cheetah versions: 2.2.2 and 2.4.0
OS: gentoo linux
Python: 2.6.1, 2.6.2
Patch follows:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
--- /root/Compiler.py 2009-11-24 23:21:24.000000000 -0300
+++ Compiler.py 2009-11-24 23:20:03.000000000 -0300
@@ -1569,7 +1569,7 @@
else:
unicodeMatch = unicodeDirectiveRE.search(source)
- encodingMatch = encodingDirectiveRE.match(source)
+ encodingMatch = encodingDirectiveRE.search(source)
if unicodeMatch:
if encodingMatch:
raise ParseError(
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july