Wiki source code of Encoding
Version 7.1 by Sergiu Dumitriu on 2008/06/25
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | 1 XWiki Character Encoding Configuration | ||
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. | ||
4 | |||
5 | 1.1 XWiki encoding | ||
6 | |||
7 | Change the charset enconding in these XWiki files : | ||
8 | |||
9 | * *web.xml*: locate the filter class com.xpn.xwiki.web.SetCharacterEncodingFilter and change it to UTF-8. It should look like this | ||
10 | |||
11 | {code:xml} | ||
12 | <filter> | ||
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> | ||
19 | </filter> | ||
20 | {code} | ||
21 | |||
22 | * *xwiki.cfg* : locate the line containing xwiki.encoding and change it to look like this | ||
23 | {code} | ||
24 | xwiki.encoding = UTF-8 | ||
25 | {code} | ||
26 | |||
27 | 1.1 HTML encoding | ||
28 | |||
29 | Change the HTML encoding in XWiki through Administration --> Preferences --> Presentation --> HTTP Meta information. Inside this textbox locate the *Content-type* meta tag and make it look like this, changing the encoding to UTF-8 | ||
30 | {code:xml} | ||
31 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | ||
32 | {code} | ||
33 | |||
34 | |||
35 | 1.1 Hibernate configuration | ||
36 | Add the following lines in the <tt>hibernate.cfg.xml</tt> file: | ||
37 | {code:xml} | ||
38 | <property name="connection.useUnicode">true</property> | ||
39 | <property name="connection.characterEncoding">UTF-8</property> | ||
40 | {code} | ||
41 | |||
42 | 1.1 MySQL configuration | ||
43 | |||
44 | It's common practice that the MySQL configuration file, in \*nix systems is located in /etc/mysql/my.cnf | ||
45 | {code} | ||
46 | [client] | ||
47 | default-character-set=utf8 | ||
48 | [mysqld] | ||
49 | default-character-set=utf8 | ||
50 | character-set-server = utf8 | ||
51 | collation-server = utf8_general_ci | ||
52 | {code} | ||
53 | |||
54 | 1.1 Java application server (Tomcat or Jetty for instance) | ||
55 | |||
56 | 1.1.1 Jetty | ||
57 | |||
58 | {code} | ||
59 | echo off | ||
60 | rem set LANG=fr_FR.ISO8859-1 | ||
61 | set LANG=en_US.UTF-8 | ||
62 | set JETTY_PORT=8080 | ||
63 | set JETTY_HOME=. | ||
64 | java %JAVA_OPTS% -Djetty.port=%JETTY_PORT% -Djetty.home=%JETTY_HOME% -Dfile.encoding=UTF-8 -jar %JETTY_HOME%/start.jar | ||
65 | {code} | ||
66 | |||
67 | Instead of config system variable LANG you can use JVM properties | ||
68 | |||
69 | {code} | ||
70 | -Duser.language=en | ||
71 | -Duser.country=US | ||
72 | {code} | ||
73 | |||
74 | in server startup script. | ||
75 | |||
76 | 1.1.1 Tomcat | ||
77 | |||
78 | In order to enable UTF-8 in tomcat, you have to add | ||
79 | |||
80 | {code} | ||
81 | URIEncoding="UTF-8" | ||
82 | {code} | ||
83 | |||
84 | to each connector enabled/used in *conf/server.xml*. | ||
85 | For example the non-SSL HTTP Connector should read: | ||
86 | |||
87 | {code:xml} | ||
88 | <Connector port="8080" maxHttpHeaderSize="8192" | ||
89 | maxThreads="150" minSpareThreads="25" maxSpareThreads="75" | ||
90 | enableLookups="false" redirectPort="8443" acceptCount="100" | ||
91 | connectionTimeout="20000" disableUploadTimeout="true" | ||
92 | URIEncoding="UTF-8"/> | ||
93 | {code} | ||
94 | #warn("In case you're using AJP to connect Tomcat and httpd, make sure you add this attribute to the AJP connector.") | ||
95 | |||
96 | 1.1 System config | ||
97 | |||
98 | Add the following variables to your system | ||
99 | |||
100 | {code} | ||
101 | LANG = en_US.UTF-8 | ||
102 | {code} | ||
103 | |||
104 | Credits: http://www.nabble.com/Re%3A-problem-with-Chinese-p9547507.html |