Version 12.5 by yann on 2010/09/03

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

Get Connected