Set Python27 Google Appengine Default Encoding For Entire App
I would like to set the default encoding to utf-8 for my python27 appengine site. The default is ascii. There was a similar question answered http://code.google.com/p/googleappengi
Solution 1:
You can start your python 27 code (every Python file) with:
#!/usr/bin/python# -*- coding: utf-8 -*-
from __future__ import unicode_literals
But sometimes you have to use .encode('ascii') if you use HMAC or you have to set http headers. Or you can use:
self.response.headers[str('Content-Type')] = str(content_type)
or
self.response.headers[b'Content-Type'] = str(content_type)
And make sure:
- all your HTML files use UTF-8
- your editor uses UTF-8 by default
Post a Comment for "Set Python27 Google Appengine Default Encoding For Entire App"