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