Version 13.1 by Guillaume Fenollar on 2011/01/18

Show last authors
1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc/}}
3 {{/box}}
4
5 Here is below the configuration for UTF-8. Note that this is valid for XWiki 1.0 b5 and above. Easier configuration might be provided for upcoming releases.
6
7 = XWiki encoding =
8
9 Change the charset enconding in these XWiki files :
10
11 * **web.xml**: locate the filter class com.xpn.xwiki.web.SetCharacterEncodingFilter and change it to UTF-8. It should look like this
12
13 {{code language="xml"}}
14 <filter>
15 <filter-name>Set Character Encoding</filter-name>
16 <filter-class>com.xpn.xwiki.web.SetCharacterEncodingFilter</filter-class>
17 <init-param>
18 <param-name>encoding</param-name>
19 <param-value>UTF-8</param-value>
20 </init-param>
21 </filter>
22 {{/code}}
23
24 * **xwiki.cfg** : locate the line containing xwiki.encoding and change it to look like this
25
26 {{code}}
27 xwiki.encoding = UTF-8
28 {{/code}}
29
30 = HTML encoding =
31
32 Change the HTML encoding in XWiki through Administration ~-~-> Preferences ~-~-> Presentation ~-~-> HTTP Meta information.
33
34 {{warning}}
35 This is Administration ~--> Presentation then look for Header ~--> HTTP Meta Information in more recent XWiki default wikis
36 {{/warning}}
37
38 Inside this textbox locate the **Content-type** meta tag and make it look like this, changing the encoding to UTF-8
39
40 {{code language="xml"}}
41 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
42 {{/code}}
43
44 {{warning}}
45 This step is not needed if you have the following. Instead that line can be left alone.
46 {{/warning}}
47
48 {{code language="xml"}}
49 <meta http-equiv="Content-Type" content="text/html; charset=$!xwiki.encoding" />
50 {{/code}}
51
52 = Hibernate configuration =
53
54 Add the following lines in the ##hibernate.cfg.xml## file:
55
56 {{code language="xml"}}
57 <property name="connection.useUnicode">true</property>
58 <property name="connection.characterEncoding">UTF-8</property>
59 {{/code}}
60
61 = MySQL configuration =
62
63 It's common practice that the MySQL configuration file, in *nix systems is located in /etc/mysql/my.cnf
64
65 {{code}}
66 [client]
67 default-character-set=utf8
68 [mysqld]
69 default-character-set=utf8
70 character-set-server = utf8
71 collation-server = utf8_bin
72 {{/code}}
73
74 = Servlet Container =
75
76 == Jetty ==
77
78 {{code}}echo off
79 rem set LANG=fr_FR.ISO8859-1
80 set LANG=en_US.UTF-8
81 set JETTY_PORT=8080
82 set JETTY_HOME=.
83 java %JAVA_OPTS% -Djetty.port=%JETTY_PORT% -Djetty.home=%JETTY_HOME% -Dfile.encoding=UTF-8 -jar %JETTY_HOME%/start.jar{{/code}}
84 Instead of config system variable LANG you can use JVM properties
85
86 {{code}}
87 -Duser.language=en
88 -Duser.country=US
89 {{/code}}
90
91 in server startup script.
92
93 == Tomcat ==
94
95 In order to enable UTF-8 in tomcat, you have to add
96
97 {{code}}
98 URIEncoding="UTF-8"
99 {{/code}}
100
101 to each connector enabled/used in **conf/server.xml**. For example the non-SSL HTTP Connector should read:
102
103 {{code language="xml"}}
104 <Connector port="8080" maxHttpHeaderSize="8192"
105 maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
106 enableLookups="false" redirectPort="8443" acceptCount="100"
107 connectionTimeout="20000" disableUploadTimeout="true"
108 URIEncoding="UTF-8"/>
109 {{/code}}
110
111 {{warning}}
112 In case you're using AJP to connect Tomcat and httpd, make sure you add this attribute to the AJP connector.
113 {{/warning}}
114
115 == [[Glassfish>>http://www.glassfish.org/]] ==
116
117 To run xwiki with UTF-8 in Glassfish you will need to recreate the xwiki-enterprise.war file and do a change to the glassfish config. First, in the Administration GUI under Domain => General => Locale enter en_US.UTF-8.
118
119 Now you will need to add all the aforementioned changes from this document to the files in the war file, create a new warfile, and deploy that one to you glassfish installations. This is required due to the fact that Glassfish will not accept changes to a deployed web.xml file. So you need to deploy a ready changed web.xml file inside your war file becuase all subsequent changes to the deployed web.xml file in the filesystem are totally ignored.
120
121 Create a new directory that we will use as a temporary place to edit our war file
122
123 {{code}}
124 mkdir xwikitmp
125 {{/code}}
126
127 Unpack the warfile:
128
129 {{code}}
130 cd xwikitemp;jar xvf ../xwiki-enterprise-web-1.5.war
131 {{/code}}
132
133 Edit the files as mentioned in the beginning of this article:
134
135 * wiki.cfg
136 * web.xml
137 * hibernate.cfg.xml
138
139 Now lets create a new warfile which contains all the changes:
140
141 {{code}}
142 jar cvf ../xwiki-enterprise-web-local-1.5.war .
143 {{/code}}
144
145 Now you can deploy your new .war file to Glassfish and it will have all the changes in it and wll be correctly deployed.
146
147 = System config =
148
149 Add the following variables to your system
150
151 {{code}}
152 LANG = en_US.UTF-8
153 {{/code}}
154
155 Credits: http://www.nabble.com/Re%3A-problem-with-Chinese-p9547507.html

Get Connected