Version 12.2 by Silvia Macovei on 2010/03/03

Hide last authors
Silvia Macovei 12.2 1 {{box cssClass="floatinginfobox" title="**Contents**"}}{{toc/}}{{/box}}
slauriere 1.1 2
Vincent Massol 1.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.
slauriere 1.1 4
Silvia Macovei 12.2 5 = XWiki encoding =
slauriere 1.1 6
bitman09 1.8 7 Change the charset enconding in these XWiki files :
8
Silvia Macovei 12.1 9 * **web.xml**: locate the filter class com.xpn.xwiki.web.SetCharacterEncodingFilter and change it to UTF-8. It should look like this
slauriere 1.1 10
Silvia Macovei 12.1 11 {{code language="xml"}}
bitman09 1.10 12 <filter>
bitman09 1.9 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>
bitman09 1.10 19 </filter>
Silvia Macovei 12.1 20 {{/code}}
bitman09 1.8 21
Silvia Macovei 12.1 22 * **xwiki.cfg** : locate the line containing xwiki.encoding and change it to look like this
23
24 {{code}}
bitman09 1.9 25 xwiki.encoding = UTF-8
Silvia Macovei 12.1 26 {{/code}}
bitman09 1.9 27
Silvia Macovei 12.2 28 = HTML encoding =
bitman09 1.9 29
Silvia Macovei 12.1 30 Change the HTML encoding in XWiki through Administration ~-~-> Preferences ~-~-> Presentation ~-~-> HTTP Meta information.
LuisArias 11.1 31
Silvia Macovei 12.1 32 {{warning}}
33 This is Administration ~--> Presentation then look for Header ~--> HTTP Meta Information in more recent XWiki default wikis
34 {{/warning}}
LuisArias 11.1 35
Silvia Macovei 12.1 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"}}
bitman09 1.14 39 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Silvia Macovei 12.1 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"}}
LuisArias 11.1 47 <meta http-equiv="Content-Type" content="text/html; charset=$!xwiki.encoding" />
Silvia Macovei 12.1 48 {{/code}}
bitman09 1.10 49
Silvia Macovei 12.2 50 = Hibernate configuration =
bitman09 1.15 51
Silvia Macovei 12.1 52 Add the following lines in the ##hibernate.cfg.xml## file:
53
54 {{code language="xml"}}
Sergiu Dumitriu 1.6 55 <property name="connection.useUnicode">true</property>
56 <property name="connection.characterEncoding">UTF-8</property>
Silvia Macovei 12.1 57 {{/code}}
Sergiu Dumitriu 1.6 58
Silvia Macovei 12.2 59 = MySQL configuration =
slauriere 1.1 60
Silvia Macovei 12.1 61 It's common practice that the MySQL configuration file, in *nix systems is located in /etc/mysql/my.cnf
62
63 {{code}}
slauriere 1.1 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
Silvia Macovei 12.1 70 {{/code}}
slauriere 1.1 71
Silvia Macovei 12.2 72 = Servlet Container =
slauriere 1.1 73
Silvia Macovei 12.2 74 == Jetty ==
Silvia Macovei 12.1 75
76 {{code}}echo off
slauriere 1.1 77 rem set LANG=fr_FR.ISO8859-1
78 set LANG=en_US.UTF-8
79 set JETTY_PORT=8080
80 set JETTY_HOME=.
Silvia Macovei 12.1 81 java %JAVA_OPTS% -Djetty.port=%JETTY_PORT% -Djetty.home=%JETTY_HOME% -Dfile.encoding=UTF-8 -jar %JETTY_HOME%/start.jar{{/code}}
machac 1.4 82 Instead of config system variable LANG you can use JVM properties
83
Silvia Macovei 12.1 84 {{code}}
machac 1.4 85 -Duser.language=en
86 -Duser.country=US
Silvia Macovei 12.1 87 {{/code}}
machac 1.4 88
89 in server startup script.
90
Silvia Macovei 12.2 91 == Tomcat ==
aanno 3.1 92
93 In order to enable UTF-8 in tomcat, you have to add
94
Silvia Macovei 12.1 95 {{code}}
Sergiu Dumitriu 6.1 96 URIEncoding="UTF-8"
Silvia Macovei 12.1 97 {{/code}}
aanno 3.1 98
Silvia Macovei 12.1 99 to each connector enabled/used in **conf/server.xml**. For example the non-SSL HTTP Connector should read:
aanno 3.1 100
Silvia Macovei 12.1 101 {{code language="xml"}}
aanno 3.1 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"
Sergiu Dumitriu 6.1 106 URIEncoding="UTF-8"/>
Silvia Macovei 12.1 107 {{/code}}
aanno 3.1 108
Silvia Macovei 12.1 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}}
cypromis 9.1 112
Silvia Macovei 12.2 113 == [[Glassfish>>http://www.glassfish.org/]] ==
cypromis 9.1 114
Silvia Macovei 12.1 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.
cypromis 9.1 116
Silvia Macovei 12.1 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
cypromis 9.1 119 Create a new directory that we will use as a temporary place to edit our war file
Silvia Macovei 12.1 120
121 {{code}}
122 mkdir xwikitmp
123 {{/code}}
124
cypromis 9.1 125 Unpack the warfile:
Silvia Macovei 12.1 126
127 {{code}}
128 cd xwikitemp;jar xvf ../xwiki-enterprise-web-1.5.war
129 {{/code}}
130
cypromis 9.1 131 Edit the files as mentioned in the beginning of this article:
Silvia Macovei 12.1 132
cypromis 9.1 133 * wiki.cfg
134 * web.xml
135 * hibernate.cfg.xml
Silvia Macovei 12.1 136
cypromis 9.1 137 Now lets create a new warfile which contains all the changes:
138
Silvia Macovei 12.1 139 {{code}}
140 jar cvf ../xwiki-enterprise-web-local-1.5.war .
141 {{/code}}
142
cypromis 9.1 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
Silvia Macovei 12.2 145 = System config =
cypromis 9.1 146
slauriere 1.1 147 Add the following variables to your system
148
Silvia Macovei 12.1 149 {{code}}
WilliamLesguillier 2.1 150 LANG = en_US.UTF-8
Silvia Macovei 12.1 151 {{/code}}
slauriere 1.1 152
153 Credits: http://www.nabble.com/Re%3A-problem-with-Chinese-p9547507.html

Get Connected