Last modified by Pascal Robert on 2015/05/04 04:24

From version 3.1
edited by Quinton Dolan
on 2007/07/12 20:48
Change comment: There is no comment for this version
To version 4.1
edited by Pascal Robert
on 2007/09/03 15:13
Change comment: There is no comment for this version

Summary

Details

Page properties
Title
... ... @@ -1,1 +1,1 @@
1 -Programming__WebObjects-Web Applications-Development-Localization and Internationalization
1 +Web Applications-Development-Localization and Internationalization
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.qdolan
1 +XWiki.probert
Content
... ... @@ -1,4 +1,4 @@
1 -== Unicode ==
1 +== Unicode ==
2 2  
3 3  To Enable Unicode for your WO app, add the following to your application constructor:
4 4  
... ... @@ -21,7 +21,7 @@
21 21  
22 22  {{/code}}
23 23  
24 -=== Jesse Barnum ===
24 +=== Jesse Barnum ===
25 25  
26 26  Great tip - here is a simple method call you can stick in your Application object to automatically achieve the results outlined above:
27 27  
... ... @@ -37,7 +37,7 @@
37 37  public WOResponse dispatchRequest(WORequest theRequest) {
38 38   WOResponse result = super.dispatchRequest(theRequest);
39 39   if( enableUTFEncoding && "text/html".equals(result.headerForKey("content-type")) ) {
40 - result.setHeader("text/html; charset=UTF-8; encoding=UTF-8", "content-type");
40 + result.setHeader("text/html; charset=UTF-8; encoding=UTF-8", "content-type");
41 41   }
42 42   return result;
43 43  }
... ... @@ -44,7 +44,7 @@
44 44  
45 45  {{/code}}
46 46  
47 -=== Helmut Schottmüller ===
47 +=== Helmut Schottmüller ===
48 48  
49 49  Unfortunately it's not so easy if you want to use file upload fields and UTF-8 encoding in the same form. Adding a file upload component means that you have to set the form's enctype to "multipart/form-data". To force a multipart form to use UTF-8 encoding usually needs an enctype of "multipart/form-data; charset=UTF-8" but WO is not able to identify such a form as multipart form. You will get a "java.lang.IllegalArgumentException: This form is missing a 'enctype=multipart/form-data' attribute. It is required for WOFileUpload to work." error when you open the form in the browser.
50 50  
... ... @@ -52,9 +52,9 @@
52 52  
53 53  {{code}}
54 54  
55 -public WORequest createRequest(String aMethod, String aURL, String anHTTPVersion,
55 +public WORequest createRequest(String aMethod, String aURL, String anHTTPVersion,
56 56   NSDictionary someHeaders, NSData aContent, NSDictionary someInfo) {
57 - WORequest newRequest = super.createRequest(aMethod, aURL, anHTTPVersion,
57 + WORequest newRequest = super.createRequest(aMethod, aURL, anHTTPVersion,
58 58   someHeaders, aContent, someInfo);
59 59   newRequest.setDefaultFormValueEncoding(_NSUtilities.UTF8StringEncoding);
60 60   return newRequest;
... ... @@ -62,10 +62,8 @@
62 62  
63 63  {{/code}}
64 64  
65 -To make WOFileUpload components working I also had to add the launch parameter --WOUseLegacyMultipartParser true to my application. This launch parameter forces the parsing of all form values, the first time WORequest.formValues is called. See the [[apple developer documentation>>http://developer.apple.com/documentation/WebObjects/Reference/api/com/webobjects/appserver/WORequest.html]] for additional information. Without --WOUseLegacyMultipartParser true I had serious problems in my applications using a WOFileUpload component because the bindings //data// and //filePath// have been emptied after a form POST.
65 +To make WOFileUpload components working I also had to add the launch parameter WOUseLegacyMultipartParser true to my application. This launch parameter forces the parsing of all form values, the first time WORequest.formValues is called. See the [[apple developer documentation>>http://developer.apple.com/documentation/WebObjects/Reference/api/com/webobjects/appserver/WORequest.html]] for additional information. Without WOUseLegacyMultipartParser true I had serious problems in my applications using a WOFileUpload component because the bindings //data// and //filePath// have been emptied after a form POST.
66 66  
67 67  With Jesse's code and this extension, you will be able to handle UTF-8 character data correctly in your WO application.
68 68  
69 69  If you use localized strings in your UTF-8 application you may also check out Project Wonder's [[ERXLocalizer>>Programming__WebObjects-WOnder-ERXLocalizer]] class.
70 -
71 -Category:WebObjects