char encoding in DirectAction requests?
Will Scheidegger <[email protected]>
| Newsgroups | gmane.comp.web.webobjects.devel |
|---|---|
| Message-ID | <[email protected]> |
Once again I'm struggling with character encoding. My app is supposed
to encode everything in UTF-8, so I got the following in my code:
In "Application":
- WORequest.setDefaultURLEncoding("UTF-8");
- public void takeValuesFromRequest(WORequest aRequest, WOContext
aContext) {
aRequest.setDefaultFormValueEncoding
( _NSUtilities.UTF8StringEncoding );
super.takeValuesFromRequest(aRequest, aContext);
}
- public WOResponse createResponseInContext(WOContext context) {
WOResponse response = super.createResponseInContext(context);
response.setContentEncoding( _NSUtilities.UTF8StringEncoding);
return response;
}
- public void appendToResponse(WOResponse response, WOContext context) {
super.appendToResponse(response, context);
if (_NSUtilities.UTF8StringEncoding.equals(response.contentEncoding
())) {
response.setHeader("text/html; charset=UTF-8", "Content-Type");
}
}
In "Session":
- public void takeValuesFromRequest(WORequest aRequest, WOContext
aContext) {
aRequest.setDefaultFormValueEncoding
( _NSUtilities.UTF8StringEncoding );
super.takeValuesFromRequest(aRequest, aContext);
}
Even in the html:
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Still, when I submit the for using a direct action, I'm getting
crippled data when the user entered non-ascii characters. Needles to
say that everything works fine (including chinese and japanese
characters) when the data is submitted using a regular form and a
component action.
I've searched the web and looked at "Practical WebObjects" chapter 8
but did not find an answer yet.
-Will