Version 15.3 by lich on 2012/12/24

Hide last authors
Guillaume Fenollar 13.1 1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc/}}
3 {{/box}}
slauriere 1.1 4
Manuel Smeria 15.2 5 Below you have 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 6
Silvia Macovei 12.2 7 = XWiki encoding =
slauriere 1.1 8
Manuel Smeria 15.2 9 Change the charset enconding in these XWiki files:
bitman09 1.8 10
Manuel Smeria 15.2 11 * **web.xml**: locate the filter class ##com.xpn.xwiki.web.SetCharacterEncodingFilter## and change it to UTF-8. It should look like this:
12 (((
Silvia Macovei 12.1 13 {{code language="xml"}}
bitman09 1.10 14 <filter>
bitman09 1.9 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>
bitman09 1.10 21 </filter>
Silvia Macovei 12.1 22 {{/code}}
Manuel Smeria 15.2 23 )))
24 * **xwiki.cfg** : locate the line containing ##xwiki.encoding## and change it to look like this:
25 (((
Silvia Macovei 12.1 26 {{code}}
bitman09 1.9 27 xwiki.encoding = UTF-8
Silvia Macovei 12.1 28 {{/code}}
Manuel Smeria 15.2 29 )))
bitman09 1.9 30
Silvia Macovei 12.2 31 = HTML encoding =
bitman09 1.9 32
Silvia Macovei 12.1 33 Change the HTML encoding in XWiki through Administration ~-~-> Preferences ~-~-> Presentation ~-~-> HTTP Meta information.
LuisArias 11.1 34
Silvia Macovei 12.1 35 {{warning}}
36 This is Administration ~--> Presentation then look for Header ~--> HTTP Meta Information in more recent XWiki default wikis
37 {{/warning}}
LuisArias 11.1 38
Silvia Macovei 12.1 39 Inside this textbox locate the **Content-type** meta tag and make it look like this, changing the encoding to UTF-8
40
41 {{code language="xml"}}
bitman09 1.14 42 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Silvia Macovei 12.1 43 {{/code}}
44
45 {{warning}}
46 This step is not needed if you have the following. Instead that line can be left alone.
47 {{/warning}}
48
49 {{code language="xml"}}
LuisArias 11.1 50 <meta http-equiv="Content-Type" content="text/html; charset=$!xwiki.encoding" />
Silvia Macovei 12.1 51 {{/code}}
bitman09 1.10 52
Silvia Macovei 12.2 53 = Hibernate configuration =
bitman09 1.15 54
Silvia Macovei 12.1 55 Add the following lines in the ##hibernate.cfg.xml## file:
56
57 {{code language="xml"}}
Sergiu Dumitriu 1.6 58 <property name="connection.useUnicode">true</property>
59 <property name="connection.characterEncoding">UTF-8</property>
Silvia Macovei 12.1 60 {{/code}}
Sergiu Dumitriu 1.6 61
Silvia Macovei 12.2 62 = MySQL configuration =
slauriere 1.1 63
Manuel Smeria 15.2 64 It's common practice that the MySQL configuration file, in *nix systems is located in $$/etc/mysql/my.cnf##:
Silvia Macovei 12.1 65
66 {{code}}
slauriere 1.1 67 [client]
68 default-character-set=utf8
69 [mysqld]
70 default-character-set=utf8
71 character-set-server = utf8
Guillaume Fenollar 13.1 72 collation-server = utf8_bin
Silvia Macovei 12.1 73 {{/code}}
slauriere 1.1 74
Silvia Macovei 12.2 75 = Servlet Container =
slauriere 1.1 76
Silvia Macovei 12.2 77 == Jetty ==
Silvia Macovei 12.1 78
79 {{code}}echo off
slauriere 1.1 80 rem set LANG=fr_FR.ISO8859-1
81 set LANG=en_US.UTF-8
82 set JETTY_PORT=8080
83 set JETTY_HOME=.
Manuel Smeria 15.2 84 java %JAVA_OPTS% -Djetty.port=%JETTY_PORT% -Djetty.home=%JETTY_HOME% -Dfile.encoding=UTF-8 -jar %JETTY_HOME%/start.jar
85 {{/code}}
machac 1.4 86
Manuel Smeria 15.2 87 Instead of the config system variable LANG you can use JVM properties.
88
Silvia Macovei 12.1 89 {{code}}
machac 1.4 90 -Duser.language=en
91 -Duser.country=US
Silvia Macovei 12.1 92 {{/code}}
machac 1.4 93
94 in server startup script.
95
Silvia Macovei 12.2 96 == Tomcat ==
aanno 3.1 97
98 In order to enable UTF-8 in tomcat, you have to add
99
Silvia Macovei 12.1 100 {{code}}
Sergiu Dumitriu 6.1 101 URIEncoding="UTF-8"
Silvia Macovei 12.1 102 {{/code}}
aanno 3.1 103
Manuel Smeria 15.2 104 to each connector enabled/used in ##conf/server.xml##. For example the non-SSL HTTP Connector should read:
aanno 3.1 105
Silvia Macovei 12.1 106 {{code language="xml"}}
aanno 3.1 107 <Connector port="8080" maxHttpHeaderSize="8192"
108 maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
109 enableLookups="false" redirectPort="8443" acceptCount="100"
110 connectionTimeout="20000" disableUploadTimeout="true"
Sergiu Dumitriu 6.1 111 URIEncoding="UTF-8"/>
Silvia Macovei 12.1 112 {{/code}}
aanno 3.1 113
Silvia Macovei 12.1 114 {{warning}}
115 In case you're using AJP to connect Tomcat and httpd, make sure you add this attribute to the AJP connector.
116 {{/warning}}
cypromis 9.1 117
Manuel Smeria 15.2 118 == [[Glassfish>>http://glassfish.java.net/]] ==
cypromis 9.1 119
Manuel Smeria 15.2 120 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 121
Manuel Smeria 15.2 122 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 your glassfish installation. 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 because all subsequent changes to the deployed **web.xml** file in the filesystem are totally ignored.
Silvia Macovei 12.1 123
Manuel Smeria 15.2 124 Create a new directory that we will use as a temporary place to edit our war file:
Silvia Macovei 12.1 125
126 {{code}}
127 mkdir xwikitmp
128 {{/code}}
129
cypromis 9.1 130 Unpack the warfile:
Silvia Macovei 12.1 131
132 {{code}}
133 cd xwikitemp;jar xvf ../xwiki-enterprise-web-1.5.war
134 {{/code}}
135
cypromis 9.1 136 Edit the files as mentioned in the beginning of this article:
Silvia Macovei 12.1 137
cypromis 9.1 138 * wiki.cfg
139 * web.xml
140 * hibernate.cfg.xml
Silvia Macovei 12.1 141
Manuel Smeria 15.2 142 Now let's create a new warfile which contains all the changes:
cypromis 9.1 143
Silvia Macovei 12.1 144 {{code}}
145 jar cvf ../xwiki-enterprise-web-local-1.5.war .
146 {{/code}}
147
cypromis 9.1 148 Now you can deploy your new .war file to Glassfish and it will have all the changes in it and wll be correctly deployed.
149
Silvia Macovei 12.2 150 = System config =
cypromis 9.1 151
Manuel Smeria 15.2 152 Add the following variables to your system:
slauriere 1.1 153
Silvia Macovei 12.1 154 {{code}}
WilliamLesguillier 2.1 155 LANG = en_US.UTF-8
Silvia Macovei 12.1 156 {{/code}}
slauriere 1.1 157
Manuel Smeria 15.2 158 [[Credits>>http://markmail.org/message/qitvntzz7cwpyo2w]]
petskratt 15.1 159
160 = OpenOffice import =
161
Manuel Smeria 15.2 162 If OpenOffice import turns characters into question marks or HTML Entity you need to edit **registrymodifications.xcu** located in user profile used by the OO server by adding:
petskratt 15.1 163
164 {{code}}
165 <item
166 oor:path="/org.openoffice.Office.Common/Filter/HTML/Export"><prop
167 oor:name="Encoding" oor:op="fuse"><value>76</value></prop></item>
168 {{/code}}
169
Manuel Smeria 15.2 170 [[Credits>>http://lists.xwiki.org/pipermail/users/2011-November/021004.html]]

Get Connected