I\'m using Python 2.6 and Jinja2 to create HTML reports. I provide the template with many results and the template loops through them and creates HTML tables
When callin
If you get an error with a string like "ABC", maybe the non-ASCII character is somewhere else. In the template source perhaps?
In any case, use Unicode strings throughout your application to avoid this kind of problems. If your data source provides you with byte strings, you get unicode strings with byte_string.decode('utf-8')
, if the string is encoded in UTF-8. If your source is a file, use the StreamReader
class in the codecs module.
If you're unsure about the difference between Unicode strings and regular strings, read this: http://www.joelonsoftware.com/articles/Unicode.html