Wiki source code of XWiki Character Encoding Configuration
Version 18.1 by Thomas Mortagne on 2015/10/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 | |
![]() |
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:((( |
![]() |
12.1 | 12 | {{code language="xml"}} |
![]() |
1.10 | 13 | <filter> |
![]() |
1.9 | 14 | <filter-name>Set Character Encoding</filter-name> |
![]() |
17.1 | 15 | <filter-class>org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter</filter-class> |
![]() |
1.9 | 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 | = MySQL configuration = |
![]() |
1.1 | 52 | |
![]() |
16.1 | 53 | It's common practice that the MySQL configuration file, in *nix systems is located in $$/etc/mysql/my.cnf##:## |
![]() |
16.2 | 54 | Starting with MySQL 5.5.3 the option 'default-character-set=utf8' is deprecated under [mysql] |
![]() |
12.1 | 55 | |
56 | {{code}} | ||
![]() |
1.1 | 57 | [client] |
58 | default-character-set=utf8 | ||
59 | [mysqld] | ||
60 | default-character-set=utf8 | ||
61 | character-set-server = utf8 | ||
![]() |
13.1 | 62 | collation-server = utf8_bin |
![]() |
12.1 | 63 | {{/code}} |
![]() |
1.1 | 64 | |
![]() |
16.2 | 65 | **After 5.5.3** |
66 | |||
67 | {{code}} | ||
68 | [client] | ||
69 | default-character-set=utf8 | ||
70 | [mysqld] | ||
71 | character-set-server = utf8 | ||
72 | collation-server = utf8_bin | ||
73 | {{/code}} | ||
74 | |||
75 | |||
76 | |||
![]() |
12.2 | 77 | = Servlet Container = |
![]() |
1.1 | 78 | |
![]() |
12.2 | 79 | == Jetty == |
![]() |
12.1 | 80 | |
![]() |
16.1 | 81 | {{code}} |
82 | echo off | ||
![]() |
1.1 | 83 | rem set LANG=fr_FR.ISO8859-1 |
84 | set LANG=en_US.UTF-8 | ||
85 | set JETTY_PORT=8080 | ||
86 | set JETTY_HOME=. | ||
![]() |
15.2 | 87 | java %JAVA_OPTS% -Djetty.port=%JETTY_PORT% -Djetty.home=%JETTY_HOME% -Dfile.encoding=UTF-8 -jar %JETTY_HOME%/start.jar |
88 | {{/code}} | ||
![]() |
1.4 | 89 | |
![]() |
15.2 | 90 | Instead of the config system variable LANG you can use JVM properties. |
91 | |||
![]() |
12.1 | 92 | {{code}} |
![]() |
1.4 | 93 | -Duser.language=en |
94 | -Duser.country=US | ||
![]() |
12.1 | 95 | {{/code}} |
![]() |
1.4 | 96 | |
97 | in server startup script. | ||
98 | |||
![]() |
12.2 | 99 | == Tomcat == |
![]() |
3.1 | 100 | |
101 | In order to enable UTF-8 in tomcat, you have to add | ||
102 | |||
![]() |
12.1 | 103 | {{code}} |
![]() |
6.1 | 104 | URIEncoding="UTF-8" |
![]() |
12.1 | 105 | {{/code}} |
![]() |
3.1 | 106 | |
![]() |
15.2 | 107 | to each connector enabled/used in ##conf/server.xml##. For example the non-SSL HTTP Connector should read: |
![]() |
3.1 | 108 | |
![]() |
12.1 | 109 | {{code language="xml"}} |
![]() |
3.1 | 110 | <Connector port="8080" maxHttpHeaderSize="8192" |
111 | maxThreads="150" minSpareThreads="25" maxSpareThreads="75" | ||
112 | enableLookups="false" redirectPort="8443" acceptCount="100" | ||
113 | connectionTimeout="20000" disableUploadTimeout="true" | ||
![]() |
6.1 | 114 | URIEncoding="UTF-8"/> |
![]() |
12.1 | 115 | {{/code}} |
![]() |
3.1 | 116 | |
![]() |
12.1 | 117 | {{warning}} |
118 | In case you're using AJP to connect Tomcat and httpd, make sure you add this attribute to the AJP connector. | ||
119 | {{/warning}} | ||
![]() |
9.1 | 120 | |
![]() |
15.2 | 121 | == [[Glassfish>>http://glassfish.java.net/]] == |
![]() |
9.1 | 122 | |
![]() |
15.2 | 123 | 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 | 124 | |
![]() |
15.2 | 125 | 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 | 126 | |
![]() |
15.2 | 127 | Create a new directory that we will use as a temporary place to edit our war file: |
![]() |
12.1 | 128 | |
129 | {{code}} | ||
130 | mkdir xwikitmp | ||
131 | {{/code}} | ||
132 | |||
![]() |
9.1 | 133 | Unpack the warfile: |
![]() |
12.1 | 134 | |
135 | {{code}} | ||
136 | cd xwikitemp;jar xvf ../xwiki-enterprise-web-1.5.war | ||
137 | {{/code}} | ||
138 | |||
![]() |
9.1 | 139 | Edit the files as mentioned in the beginning of this article: |
![]() |
12.1 | 140 | |
![]() |
9.1 | 141 | * wiki.cfg |
142 | * web.xml | ||
143 | * hibernate.cfg.xml | ||
![]() |
12.1 | 144 | |
![]() |
15.2 | 145 | Now let's create a new warfile which contains all the changes: |
![]() |
9.1 | 146 | |
![]() |
12.1 | 147 | {{code}} |
148 | jar cvf ../xwiki-enterprise-web-local-1.5.war . | ||
149 | {{/code}} | ||
150 | |||
![]() |
9.1 | 151 | Now you can deploy your new .war file to Glassfish and it will have all the changes in it and wll be correctly deployed. |
152 | |||
![]() |
12.2 | 153 | = System config = |
![]() |
9.1 | 154 | |
![]() |
15.2 | 155 | Add the following variables to your system: |
![]() |
1.1 | 156 | |
![]() |
12.1 | 157 | {{code}} |
![]() |
2.1 | 158 | LANG = en_US.UTF-8 |
![]() |
12.1 | 159 | {{/code}} |
![]() |
1.1 | 160 | |
![]() |
15.2 | 161 | [[Credits>>http://markmail.org/message/qitvntzz7cwpyo2w]] |
![]() |
15.1 | 162 | |
163 | = OpenOffice import = | ||
164 | |||
![]() |
15.2 | 165 | 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 | 166 | |
167 | {{code}} | ||
168 | <item | ||
169 | oor:path="/org.openoffice.Office.Common/Filter/HTML/Export"><prop | ||
170 | oor:name="Encoding" oor:op="fuse"><value>76</value></prop></item> | ||
171 | {{/code}} | ||
172 | |||
![]() |
15.2 | 173 | [[Credits>>http://lists.xwiki.org/pipermail/users/2011-November/021004.html]] |