I\'m trying to write my first app in Google App Engine with Python (link of the app: http://contractpy.appspot.com/ - it\'s just an experimental app). The entire code is bel
You should really use a proper templating system. Jinja2 is included with AppEngine.
However in the meantime your problem is that your templates are ASCII but your data is not (can't tell if it's utf-8 or unicode). Easy solution is to prefix each template string with u
to make it Unicode.
But, you should really use a proper templating system.
Here you got solution.
>>> "t".decode("utf-8")
u't'
>>> "\x81".decode("utf-8")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "encodings/utf_8.py", line 7799, in decode
UnicodeDecodeError: 'utf8' codec can't decode byte 0x81 in position 0: unexpected code byte
>>> "a\x81b".decode("utf-8", "replace") # this will decode better and the right way.
u'a\ufffdb'
Set default encoder at the top of your code
In appcfg.py which resides inside /google/appengine/tools/appcfg.py
on line 73 add
import sys
reload(sys)
sys.setdefaultencoding("ISO-8859-1")