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