Wiki source code of Encoding

Version 20.1 by slauriere on 2018/09/17

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
slauriere 20.1 9 Change the charset encoding in these XWiki files:
bitman09 1.8 10
Jean SIMARD 17.1 11 * **web.xml**: locate the filter class ##org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter## and change it to UTF-8. It should look like this:(((
Silvia Macovei 12.1 12 {{code language="xml"}}
bitman09 1.10 13 <filter>
bitman09 1.9 14 <filter-name>Set Character Encoding</filter-name>
Jean SIMARD 17.1 15 <filter-class>org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter</filter-class>
bitman09 1.9 16 <init-param>
17 <param-name>encoding</param-name>
18 <param-value>UTF-8</param-value>
19 </init-param>
bitman09 1.10 20 </filter>
Silvia Macovei 12.1 21 {{/code}}
Manuel Smeria 15.2 22 )))
Marius Dumitru Florea 16.1 23 * **xwiki.cfg** : locate the line containing ##xwiki.encoding## and change it to look like this:(((
Silvia Macovei 12.1 24 {{code}}
bitman09 1.9 25 xwiki.encoding = UTF-8
Silvia Macovei 12.1 26 {{/code}}
Manuel Smeria 15.2 27 )))
bitman09 1.9 28
Silvia Macovei 12.2 29 = HTML encoding =
bitman09 1.9 30
Marius Dumitru Florea 16.1 31 Change the HTML encoding in XWiki through Administration ~-~-> Look & Feel ~-~-> Page Elements ~-~-> HTTP Meta Info.
LuisArias 11.1 32
Silvia Macovei 12.1 33 {{warning}}
Marius Dumitru Florea 16.1 34 The HTTP Meta Info section was located in Administration ~--> Presentation in older versions of XWiki.
Silvia Macovei 12.1 35 {{/warning}}
LuisArias 11.1 36
Silvia Macovei 12.1 37 Inside this textbox locate the **Content-type** meta tag and make it look like this, changing the encoding to UTF-8
38
39 {{code language="xml"}}
bitman09 1.14 40 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Silvia Macovei 12.1 41 {{/code}}
42
43 {{warning}}
44 This step is not needed if you have the following. Instead that line can be left alone.
45 {{/warning}}
46
47 {{code language="xml"}}
LuisArias 11.1 48 <meta http-equiv="Content-Type" content="text/html; charset=$!xwiki.encoding" />
Silvia Macovei 12.1 49 {{/code}}
bitman09 1.10 50
slauriere 20.1 51 = Database configuration =
slauriere 1.1 52
slauriere 20.1 53 == MySQL ==
54
Marius Dumitru Florea 16.1 55 It's common practice that the MySQL configuration file, in *nix systems is located in $$/etc/mysql/my.cnf##:##
KaiSen 16.2 56 Starting with MySQL 5.5.3 the option 'default-character-set=utf8' is deprecated under [mysql]
Silvia Macovei 12.1 57
58 {{code}}
slauriere 1.1 59 [client]
60 default-character-set=utf8
61 [mysqld]
62 default-character-set=utf8
63 character-set-server = utf8
Guillaume Fenollar 13.1 64 collation-server = utf8_bin
Silvia Macovei 12.1 65 {{/code}}
slauriere 1.1 66
KaiSen 16.2 67 **After 5.5.3**
68
69 {{code}}
70 [client]
71 default-character-set=utf8
72 [mysqld]
73 character-set-server = utf8
74 collation-server = utf8_bin
75 {{/code}}
76
77
78
Silvia Macovei 12.2 79 = Servlet Container =
slauriere 1.1 80
Silvia Macovei 12.2 81 == Jetty ==
Silvia Macovei 12.1 82
Marius Dumitru Florea 16.1 83 {{code}}
84 echo off
slauriere 1.1 85 rem set LANG=fr_FR.ISO8859-1
86 set LANG=en_US.UTF-8
87 set JETTY_PORT=8080
88 set JETTY_HOME=.
Manuel Smeria 15.2 89 java %JAVA_OPTS% -Djetty.port=%JETTY_PORT% -Djetty.home=%JETTY_HOME% -Dfile.encoding=UTF-8 -jar %JETTY_HOME%/start.jar
90 {{/code}}
machac 1.4 91
Manuel Smeria 15.2 92 Instead of the config system variable LANG you can use JVM properties.
93
Silvia Macovei 12.1 94 {{code}}
machac 1.4 95 -Duser.language=en
96 -Duser.country=US
Silvia Macovei 12.1 97 {{/code}}
machac 1.4 98
99 in server startup script.
100
Silvia Macovei 12.2 101 == Tomcat ==
aanno 3.1 102
103 In order to enable UTF-8 in tomcat, you have to add
104
Silvia Macovei 12.1 105 {{code}}
Sergiu Dumitriu 6.1 106 URIEncoding="UTF-8"
Silvia Macovei 12.1 107 {{/code}}
aanno 3.1 108
Manuel Smeria 15.2 109 to each connector enabled/used in ##conf/server.xml##. For example the non-SSL HTTP Connector should read:
aanno 3.1 110
Silvia Macovei 12.1 111 {{code language="xml"}}
aanno 3.1 112 <Connector port="8080" maxHttpHeaderSize="8192"
113 maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
114 enableLookups="false" redirectPort="8443" acceptCount="100"
115 connectionTimeout="20000" disableUploadTimeout="true"
Sergiu Dumitriu 6.1 116 URIEncoding="UTF-8"/>
Silvia Macovei 12.1 117 {{/code}}
aanno 3.1 118
Silvia Macovei 12.1 119 {{warning}}
120 In case you're using AJP to connect Tomcat and httpd, make sure you add this attribute to the AJP connector.
121 {{/warning}}
cypromis 9.1 122
Manuel Smeria 15.2 123 == [[Glassfish>>http://glassfish.java.net/]] ==
cypromis 9.1 124
Vincent Massol 19.5 125 To run XWiki with UTF-8 in Glassfish you will need to recreate the XWiki 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 126
Manuel Smeria 15.2 127 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 128
Manuel Smeria 15.2 129 Create a new directory that we will use as a temporary place to edit our war file:
Silvia Macovei 12.1 130
131 {{code}}
132 mkdir xwikitmp
133 {{/code}}
134
Vincent Massol 19.6 135 Unpack the warfile (replace ##<suffix>## with the proper name for the version of XWiki you're using):
Silvia Macovei 12.1 136
137 {{code}}
Vincent Massol 19.6 138 cd xwikitemp;jar xvf ../xwiki-<suffix>.war
Silvia Macovei 12.1 139 {{/code}}
140
cypromis 9.1 141 Edit the files as mentioned in the beginning of this article:
Silvia Macovei 12.1 142
cypromis 9.1 143 * wiki.cfg
144 * web.xml
145 * hibernate.cfg.xml
Silvia Macovei 12.1 146
Manuel Smeria 15.2 147 Now let's create a new warfile which contains all the changes:
cypromis 9.1 148
Silvia Macovei 12.1 149 {{code}}
Vincent Massol 19.7 150 jar cvf ../xwiki-<suffix>.war .
Silvia Macovei 12.1 151 {{/code}}
152
cypromis 9.1 153 Now you can deploy your new .war file to Glassfish and it will have all the changes in it and wll be correctly deployed.
154
slauriere 20.1 155 = Web server =
156
157 == Apache ==
158
159 Make sure that the Apache configuration file ##httpd.conf## contains the following line:
160
161 {{code}}
162 AddDefaultCharset UTF-8
163 {{/code}}
164
Silvia Macovei 12.2 165 = System config =
cypromis 9.1 166
Manuel Smeria 15.2 167 Add the following variables to your system:
slauriere 1.1 168
Silvia Macovei 12.1 169 {{code}}
WilliamLesguillier 2.1 170 LANG = en_US.UTF-8
Silvia Macovei 12.1 171 {{/code}}
slauriere 1.1 172
Manuel Smeria 15.2 173 [[Credits>>http://markmail.org/message/qitvntzz7cwpyo2w]]
petskratt 15.1 174
175 = OpenOffice import =
176
Manuel Smeria 15.2 177 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 178
179 {{code}}
180 <item
181 oor:path="/org.openoffice.Office.Common/Filter/HTML/Export"><prop
182 oor:name="Encoding" oor:op="fuse"><value>76</value></prop></item>
183 {{/code}}
184
Manuel Smeria 15.2 185 [[Credits>>http://lists.xwiki.org/pipermail/users/2011-November/021004.html]]
slauriere 20.1 186
187 = Tools =
188
189 * The [[Admin Tools extension>>extensions:Extension.Admin Tools Application]] can be helpful to identify the values of the XWiki encoding configuration parameters on a running server.

Get Connected