cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Binkley, Peter" <Peter.Bink...@ualberta.ca>
Subject RE: Ajax forms can't handle unicode?
Date Thu, 31 Aug 2006 21:25:38 GMT
The field contents are being encoded the same when I use Ajax  and when I don't, but now that
I look at it there is a problem with the Content-Type http header. When I call an Ajax form,
I get a correctly encoded html page with "Content-Type: text/html; charset=iso-8859-1". When
I submit the form, I see two POSTs: the first one sends up all the form fields, with accented
characters correctly encoded, and with the correct content type (with charset=UTF-8); the
second one just sends these fields: "cocoon-ajax-continue=true&continuation-id=414b635f2177361e701818864f19476722597279",
and it has only "Content-Type: application/x-www-form-urlencoded" - no charset. 
 
The first POST is presumably an xmlhttprequest; it returns a block of xml like this:
 
<?xml version='1.0'?><bu:document xmlns:bu='http://apache.org/cocoon/browser-update/1.0'><bu:continue/></bu:document>
 
The second POST is presumably the actual form submission, and it returns the HTML of the upload-success
page. So it appears that the xmlhttprequest is using the correct charset, but the actual form
submission is not using the charset of the html page in which the form was found. 
 
But if I turn Ajax off, I get only one POST (of course), in which the accented characters
are encoded properly but there is no "charset=UTF-8" in the content type header, even though
there was in the response header for the html page. 
 
So: it appears that when ajax is turned off, my use of the form-encoding action is forcing
the field contents to be interpreted as UTF-8 even though Firefox isn't specifying their encoding
in the content type header; but when ajax is turned on, Cocoon is interpreting them as ISO-8859-1
even though the content type header and the form-encoding action both say they are UTF-8.

 
It's possible I've got something weird in my configuration left over from the conversion process
from 2.1.7 to 2.1.9. I'll try to create a simple test case that shows the problem based on
the samples.
 
Peter

________________________________

From: Jonas Lundberg [mailto:my.name.is.hans@gmail.com]
Sent: Thu 8/31/2006 8:04 AM
To: users@cocoon.apache.org
Subject: Re: Ajax forms can't handle unicode?



It can happen that the web browser either does not support UTF-8 for
Ajax calls, or that you have not set the Ajax call to accept UTF-8 (In
Firefox, for instance, I have not been able to set the actual encoding
for Ajax calls, although it might be possible) (Note that setting the
actual encoding is different from using an encoding description
request header.)

The easiest way, if you want a fix, is to use an encode-uri function
on the server and in the ajax javascript, then the transfer encoding
will not matter.

Regards
Hans

On 8/30/06, Binkley, Peter <Peter.Binkley@ualberta.ca> wrote:
> I'm updating an old Cforms project from 2.1.7 to 2.1.9 and adding Ajax.
> The setup is similar to the form1.flow sample, where the uploaded form
> is sent to a pipeline that starts with a jx template. I've set things up
> so form fields are interpreted as UTF-8. Everything works under 2.1.9 if
> I don't turn Ajax on (with "ajax=true" in the form template). If I do
> turn ajax on, though, any accented characters I type into a form field
> end up as question marks in the output. It appears that turning ajax on
> causes the form handling to be done in ISO-8859-1 instead of UTF-8. Has
> anyone else seen this, and is there a known fix?
>
> Thanks,
>
> Peter
>
>
> Peter Binkley
> Digital Initiatives Technology Librarian
> Information Technology Services
> 4-30 Cameron Library
> University of Alberta Libraries
> Edmonton, Alberta
> Canada T6G 2J8
> Phone: (780) 492-3743
> Fax: (780) 492-9243
> e-mail: peter.binkley@ualberta.ca
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org




Mime
View raw message