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

From version 2.1
edited by smmccraw
on 2007/07/08 09:46
Change comment: There is no comment for this version
To version 3.1
edited by Quinton Dolan
on 2007/07/12 20:48
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.smmccraw
1 +XWiki.qdolan
Content
... ... @@ -2,47 +2,47 @@
2 2  
3 3  To Enable Unicode for your WO app, add the following to your application constructor:
4 4  
5 -{{panel}}
5 +{{code}}
6 6  
7 - WOMessage.setDefaultEncoding("UTF8");
7 +WOMessage.setDefaultEncoding("UTF8");
8 8  
9 -{{/panel}}
9 +{{/code}}
10 10  
11 11  This tells all WOResponse and WORequest to use UTF8 (Unicode).
12 12  
13 13  Then you just need to tell the browser. Make all your .wo pages include this meta tag in their HTML:
14 14  
15 -{{panel}}
15 +{{code value="xml"}}
16 16  
17 - <html>
18 - <head>
19 - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
20 - <!-- etc... -->
17 +<html>
18 +<head>
19 +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
20 +<!-- etc... -->
21 21  
22 -{{/panel}}
22 +{{/code}}
23 23  
24 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  
28 -{{panel}}
28 +{{code}}
29 29  
30 - private boolean enableUTFEncoding = false;
31 -
32 - public void enableUTFEncoding() {
33 - enableUTFEncoding = true;
34 - WOMessage.setDefaultEncoding(_NSUtilities.UTF8StringEncoding);
30 +private boolean enableUTFEncoding = false;
31 +
32 +public void enableUTFEncoding() {
33 + enableUTFEncoding = true;
34 + WOMessage.setDefaultEncoding(_NSUtilities.UTF8StringEncoding);
35 +}
36 +
37 +public WOResponse dispatchRequest(WORequest theRequest) {
38 + WOResponse result = super.dispatchRequest(theRequest);
39 + if( enableUTFEncoding && "text/html".equals(result.headerForKey("content-type")) ) {
40 + result.setHeader("text/html; charset=UTF-8; encoding=UTF-8", "content-type");
35 35   }
36 -
37 - public WOResponse dispatchRequest(WORequest theRequest) {
38 - WOResponse result = super.dispatchRequest(theRequest);
39 - if( enableUTFEncoding && "text/html".equals(result.headerForKey("content-type")) ) {
40 - result.setHeader("text/html; charset=UTF-8; encoding=UTF-8", "content-type");
41 - }
42 - return result;
43 - }
42 + return result;
43 +}
44 44  
45 -{{/panel}}
45 +{{/code}}
46 46  
47 47  === Helmut Schottmüller ===
48 48  
... ... @@ -50,16 +50,17 @@
50 50  
51 51  To make sure that UTF-8 is supported in multipart forms as well, you have to add the following code to your Application object:
52 52  
53 -{{panel}}
53 +{{code}}
54 54  
55 - public WORequest createRequest(String aMethod, String aURL, String anHTTPVersion, NSDictionary someHeaders, NSData aContent, NSDictionary someInfo)
56 - {
57 - WORequest newRequest = super.createRequest(aMethod, aURL, anHTTPVersion, someHeaders, aContent, someInfo);
58 - newRequest.setDefaultFormValueEncoding(_NSUtilities.UTF8StringEncoding);
59 - return newRequest;
60 - }
55 +public WORequest createRequest(String aMethod, String aURL, String anHTTPVersion,
56 + NSDictionary someHeaders, NSData aContent, NSDictionary someInfo) {
57 + WORequest newRequest = super.createRequest(aMethod, aURL, anHTTPVersion,
58 + someHeaders, aContent, someInfo);
59 + newRequest.setDefaultFormValueEncoding(_NSUtilities.UTF8StringEncoding);
60 + return newRequest;
61 +}
61 61  
62 -{{/panel}}
63 +{{/code}}
63 63  
64 64  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 65