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