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