Re: [SOLVED by hack]: char encoding in DirectAction requests?

"Kai S. Wong" <[email protected]>
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
Hi Will,

In your Application constructor, you can initialize with the code  
below to ensure your URL properly encoded as well.

          
com.webobjects.appserver._private.WOURLEncoder.WO_URL_ENCODING = "UTF8";


Regards,
Kai


On 22-Mar-06, at 1:38 PM, Will Scheidegger wrote:

> When I had a closer look at the request object that was passed to  
> my DirectAction method I found out that its encoding was always set  
> to ISO... Now I'm manually forcing it to use UTF8 on every request:
> request().setDefaultFormValueEncoding 
> (_NSUtilities.UTF8StringEncoding);
>
> Isn't there a place where this could be set "once and for all"?
>
> -Will
>
> On 22.03.2006, at 11:16, Will Scheidegger wrote:
>
>> 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
>> _______________________________________________
>> WebObjects-dev mailing list
>> [email protected]
>> http://www.omnigroup.com/mailman/listinfo/webobjects-dev
>
> _______________________________________________
> WebObjects-dev mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/webobjects-dev
>

_______________________________________________
WebObjects-dev mailing list
[email protected]
http://www.omnigroup.com/mailman/listinfo/webobjects-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.