Response character encoding

834 views
Skip to first unread message

Peter

unread,
Jun 18, 2010, 6:42:49 AM6/18/10
to Google App Engine
Hi
I want to set the character encoding of the HTTP response to UTF-8.
In local deploying with Eclipse everythig is OK with the JVM parameter
(-Dfile.encoding="UTF-8"), but when i deploying my application to App
Engine the character encoding goes wrong, and the ajax response String
displayed in my web page is not UTF-8. What can I do? Can I set the
given JVM option to my application somehow?

Thx Peter

djidjadji

unread,
Jun 19, 2010, 11:56:47 AM6/19/10
to google-a...@googlegroups.com
You have to set the correct HTTP response header. In Python code

self.response.headers['Content-Type'] = "text/html; charset=utf-8"

2010/6/18 Peter <pcso...@gmail.com>:

> --
> You received this message because you are subscribed to the Google Groups "Google App Engine" group.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
>
>

Peter

unread,
Jun 21, 2010, 4:28:45 AM6/21/10
to Google App Engine
Thx but i allready added
response.setContentType("text/html; charset=UTF-8");
response.setCharacterEncoding("UTF-8");
Local deploy is OK only deploying to app engine is wrong.

On jún. 19, 17:56, djidjadji <djidja...@gmail.com> wrote:
> You have to set the correct HTTP response header. In Python code
>
> self.response.headers['Content-Type'] = "text/html; charset=utf-8"
>
> 2010/6/18 Peter <pcsor...@gmail.com>:

Jaroslav Záruba

unread,
Jun 21, 2010, 7:10:09 AM6/21/10
to google-a...@googlegroups.com
Sometimes I do the silly mistake of writing into outputStream instead of writer:
response.getOutputStream.print(myCharacterData); // obviously ignores charset
response.getWriter().print(myCharacterData);

Maybe...? :)

Cheers
  JZ

Peter

unread,
Jun 21, 2010, 11:29:10 AM6/21/10
to Google App Engine
Thx JZ writing into outputStream was the problem :)

Paweł Olejnik

unread,
Aug 6, 2010, 8:45:45 AM8/6/10
to Google App Engine
Hello, this is my first post to the group!
Thanks for help, I have corrected my polish language page coding
succesfully.

I have practised the above in the python code of a view class:

def get(self):

template_values =
{
}

path = os.path.join(os.path.dirname(__file__), 'some.html')
self.response.out.write(template.render(path,
template_values))
self.response.headers['Content-Type'] = "text/html;
charset=iso-8859-2"
--
You do not have to remove the header's Content-Type from the html
document
for proper editing purposes in a html editor, but the line
self.response.headers['Content-Type'] = "text/html;
charset=iso-8859-2"
has to be added after rendering of your pages to replace previous
encoding.

Thanks!
P.O.
Reply all
Reply to author
Forward
0 new messages