Wiki source code of XWiki Character Encoding Configuration
Version 16.2 by KaiSen on 2013/12/09
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
13.1 | 1 | {{box cssClass="floatinginfobox" title="**Contents**"}} |
2 | {{toc/}} | ||
3 | {{/box}} | ||
![]() |
1.1 | 4 | |
![]() |
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. |
![]() |
1.1 | 6 | |
![]() |
12.2 | 7 | = XWiki encoding = |
![]() |
1.1 | 8 | |
![]() |
15.2 | 9 | Change the charset enconding in these XWiki files: |
![]() |
1.8 | 10 | |
![]() |
16.1 | 11 | * **web.xml**: locate the filter class ##com.xpn.xwiki.web.SetCharacterEncodingFilter## and change it to UTF-8. It should look like this:((( |
![]() |
12.1 | 12 | {{code language="xml"}} |
![]() |
1.10 | 13 | <filter> |
![]() |
1.9 | 14 | <filter-name>Set Character Encoding</filter-name> |
15 | <filter-class>com.xpn.xwiki.web.SetCharacterEncodingFilter</filter-class> | ||
16 | <init-param> | ||
17 | <param-name>encoding</param-name> | ||
18 | <param-value>UTF-8</param-value> | ||
19 | </init-param> | ||
![]() |
1.10 | 20 | </filter> |
![]() |
12.1 | 21 | {{/code}} |
![]() |
15.2 | 22 | ))) |
![]() |
16.1 | 23 | * **xwiki.cfg** : locate the line containing ##xwiki.encoding## and change it to look like this:((( |
![]() |
12.1 | 24 | {{code}} |
![]() |
1.9 | 25 | xwiki.encoding = UTF-8 |
![]() |
12.1 | 26 | {{/code}} |
![]() |
15.2 | 27 | ))) |
![]() |
1.9 | 28 | |
![]() |
12.2 | 29 | = HTML encoding = |
![]() |
1.9 | 30 | |
![]() |
16.1 | 31 | Change the HTML encoding in XWiki through Administration ~-~-> Look & Feel ~-~-> Page Elements ~-~-> HTTP Meta Info. |
![]() |
11.1 | 32 | |
![]() |
12.1 | 33 | {{warning}} |
![]() |
16.1 | 34 | The HTTP Meta Info section was located in Administration ~--> Presentation in older versions of XWiki. |
![]() |
12.1 | 35 | {{/warning}} |
![]() |
11.1 | 36 | |
![]() |
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"}} | ||
![]() |
1.14 | 40 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
![]() |
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"}} | ||
![]() |
11.1 | 48 | <meta http-equiv="Content-Type" content="text/html; charset=$!xwiki.encoding" /> |
![]() |
12.1 | 49 | {{/code}} |
![]() |
1.10 | 50 | |
![]() |
12.2 | 51 | = Hibernate configuration = |
![]() |
1.15 | 52 | |
![]() |
12.1 | 53 | Add the following lines in the ##hibernate.cfg.xml## file: |
54 | |||
55 | {{code language="xml"}} | ||
![]() |
1.6 | 56 | <property name="connection.useUnicode">true</property> |
57 | <property name="connection.characterEncoding">UTF-8</property> | ||
![]() |
12.1 | 58 | {{/code}} |
![]() |
1.6 | 59 | |
![]() |
12.2 | 60 | = MySQL configuration = |
![]() |
1.1 | 61 | |
![]() |
16.1 | 62 | It's common practice that the MySQL configuration file, in *nix systems is located in $$/etc/mysql/my.cnf##:## |
![]() |
16.2 | 63 | Starting with MySQL 5.5.3 the option 'default-character-set=utf8' is deprecated under [mysql] |
![]() |
12.1 | 64 | |
65 | {{code}} | ||
![]() |
1.1 | 66 | [client] |
67 | default-character-set=utf8 | ||
68 | [mysqld] | ||
69 | default-character-set=utf8 | ||
70 | character-set-server = utf8 | ||
![]() |
13.1 | 71 | collation-server = utf8_bin |
![]() |
12.1 | 72 | {{/code}} |
![]() |
1.1 | 73 | |
![]() |
16.2 | 74 | **After 5.5.3** |
75 | |||
76 | {{code}} | ||
77 | [client] | ||
78 | default-character-set=utf8 | ||
79 | [mysqld] | ||
80 | character-set-server = utf8 | ||
81 | collation-server = utf8_bin | ||
82 | {{/code}} | ||
83 | |||
84 | |||
85 | |||
![]() |
12.2 | 86 | = Servlet Container = |
![]() |
1.1 | 87 | |
![]() |
12.2 | 88 | == Jetty == |
![]() |
12.1 | 89 | |
![]() |
16.1 | 90 | {{code}} |
91 | echo off | ||
![]() |
1.1 | 92 | rem set LANG=fr_FR.ISO8859-1 |
93 | set LANG=en_US.UTF-8 | ||
94 | set JETTY_PORT=8080 | ||
95 | set JETTY_HOME=. | ||
![]() |
15.2 | 96 | java %JAVA_OPTS% -Djetty.port=%JETTY_PORT% -Djetty.home=%JETTY_HOME% -Dfile.encoding=UTF-8 -jar %JETTY_HOME%/start.jar |
97 | {{/code}} | ||
![]() |
1.4 | 98 | |
![]() |
15.2 | 99 | Instead of the config system variable LANG you can use JVM properties. |
100 | |||
![]() |
12.1 | 101 | {{code}} |
![]() |
1.4 | 102 | -Duser.language=en |
103 | -Duser.country=US | ||
![]() |
12.1 | 104 | {{/code}} |
![]() |
1.4 | 105 | |
106 | in server startup script. | ||
107 | |||
![]() |
12.2 | 108 | == Tomcat == |
![]() |
3.1 | 109 | |
110 | In order to enable UTF-8 in tomcat, you have to add | ||
111 | |||
![]() |
12.1 | 112 | {{code}} |
![]() |
6.1 | 113 | URIEncoding="UTF-8" |
![]() |
12.1 | 114 | {{/code}} |
![]() |
3.1 | 115 | |
![]() |
15.2 | 116 | to each connector enabled/used in ##conf/server.xml##. For example the non-SSL HTTP Connector should read: |
![]() |
3.1 | 117 | |
![]() |
12.1 | 118 | {{code language="xml"}} |
![]() |
3.1 | 119 | <Connector port="8080" maxHttpHeaderSize="8192" |
120 | maxThreads="150" minSpareThreads="25" maxSpareThreads="75" | ||
121 | enableLookups="false" redirectPort="8443" acceptCount="100" | ||
122 | connectionTimeout="20000" disableUploadTimeout="true" | ||
![]() |
6.1 | 123 | URIEncoding="UTF-8"/> |
![]() |
12.1 | 124 | {{/code}} |
![]() |
3.1 | 125 | |
![]() |
12.1 | 126 | {{warning}} |
127 | In case you're using AJP to connect Tomcat and httpd, make sure you add this attribute to the AJP connector. | ||
128 | {{/warning}} | ||
![]() |
9.1 | 129 | |
![]() |
15.2 | 130 | == [[Glassfish>>http://glassfish.java.net/]] == |
![]() |
9.1 | 131 | |
![]() |
15.2 | 132 | 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**. |
![]() |
9.1 | 133 | |
![]() |
15.2 | 134 | 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. |
![]() |
12.1 | 135 | |
![]() |
15.2 | 136 | Create a new directory that we will use as a temporary place to edit our war file: |
![]() |
12.1 | 137 | |
138 | {{code}} | ||
139 | mkdir xwikitmp | ||
140 | {{/code}} | ||
141 | |||
![]() |
9.1 | 142 | Unpack the warfile: |
![]() |
12.1 | 143 | |
144 | {{code}} | ||
145 | cd xwikitemp;jar xvf ../xwiki-enterprise-web-1.5.war | ||
146 | {{/code}} | ||
147 | |||
![]() |
9.1 | 148 | Edit the files as mentioned in the beginning of this article: |
![]() |
12.1 | 149 | |
![]() |
9.1 | 150 | * wiki.cfg |
151 | * web.xml | ||
152 | * hibernate.cfg.xml | ||
![]() |
12.1 | 153 | |
![]() |
15.2 | 154 | Now let's create a new warfile which contains all the changes: |
![]() |
9.1 | 155 | |
![]() |
12.1 | 156 | {{code}} |
157 | jar cvf ../xwiki-enterprise-web-local-1.5.war . | ||
158 | {{/code}} | ||
159 | |||
![]() |
9.1 | 160 | Now you can deploy your new .war file to Glassfish and it will have all the changes in it and wll be correctly deployed. |
161 | |||
![]() |
12.2 | 162 | = System config = |
![]() |
9.1 | 163 | |
![]() |
15.2 | 164 | Add the following variables to your system: |
![]() |
1.1 | 165 | |
![]() |
12.1 | 166 | {{code}} |
![]() |
2.1 | 167 | LANG = en_US.UTF-8 |
![]() |
12.1 | 168 | {{/code}} |
![]() |
1.1 | 169 | |
![]() |
15.2 | 170 | [[Credits>>http://markmail.org/message/qitvntzz7cwpyo2w]] |
![]() |
15.1 | 171 | |
172 | = OpenOffice import = | ||
173 | |||
![]() |
15.2 | 174 | 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: |
![]() |
15.1 | 175 | |
176 | {{code}} | ||
177 | <item | ||
178 | oor:path="/org.openoffice.Office.Common/Filter/HTML/Export"><prop | ||
179 | oor:name="Encoding" oor:op="fuse"><value>76</value></prop></item> | ||
180 | {{/code}} | ||
181 | |||
![]() |
15.2 | 182 | [[Credits>>http://lists.xwiki.org/pipermail/users/2011-November/021004.html]] |