[Cheetahtemplate-discuss] Cheetah and unicode
Brought to you by:
rtyler,
tavis_rudd
From: Brian B. <bri...@se...> - 2005-07-08 14:48:26
|
Is there any liklihood that a future version of Cheetah will be able to use unicode strings directly, rather than encoding them itself. Eg. from Cheetah import Template source=u"This is a unicode template with a $variable" namespace={u"variable":u"unicode \xa3string"} t=Template.Template(source=source, searchList=[namespace]) output=str(t) # perhaps this should be: output=unicode(t) print output print type(output) This fails because Cheetah expects the "unicode \xa3string" to be able to be encoded into ascii. Instead I would like the variable "output" to be of type unicode instead of type str. At the moment I've encoded everything in utf-8 beforehand (or in a Filter) and then decoded it again at the end - but this seems very inefficient. (In case you're wondering, I'm looking at this because the output has to be translated to different encodings depending on where it's going. The same output may be latin-1 in a logfile but utf-8 in an email) Thanks, Brian |