Wiki source code of Encoding

Version 7.1 by Sergiu Dumitriu on 2008/06/25

Hide last authors
slauriere 1.1 1 1 XWiki Character Encoding Configuration
2
Vincent Massol 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.
slauriere 1.1 4
5 1.1 XWiki encoding
6
bitman09 1.8 7 Change the charset enconding in these XWiki files :
8
bitman09 1.9 9 * *web.xml*: locate the filter class com.xpn.xwiki.web.SetCharacterEncodingFilter and change it to UTF-8. It should look like this
slauriere 1.1 10
bitman09 1.10 11 {code:xml}
12 <filter>
bitman09 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>
bitman09 1.10 19 </filter>
bitman09 1.9 20 {code}
bitman09 1.8 21
bitman09 1.9 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
bitman09 1.14 27 1.1 HTML encoding
bitman09 1.9 28
bitman09 1.15 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
bitman09 1.14 30 {code:xml}
31 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
32 {code}
bitman09 1.10 33
bitman09 1.15 34
Sergiu Dumitriu 1.6 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
slauriere 1.1 42 1.1 MySQL configuration
43
bitman09 1.7 44 It's common practice that the MySQL configuration file, in \*nix systems is located in /etc/mysql/my.cnf
slauriere 1.1 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
Vincent Massol 3.2 56 1.1.1 Jetty
slauriere 1.1 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
machac 1.4 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
aanno 3.1 76 1.1.1 Tomcat
77
78 In order to enable UTF-8 in tomcat, you have to add
79
80 {code}
Sergiu Dumitriu 6.1 81 URIEncoding="UTF-8"
aanno 3.1 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"
Sergiu Dumitriu 6.1 92 URIEncoding="UTF-8"/>
aanno 3.1 93 {code}
Sergiu Dumitriu 7.1 94 #warn("In case you're using AJP to connect Tomcat and httpd, make sure you add this attribute to the AJP connector.")
aanno 3.1 95
slauriere 1.1 96 1.1 System config
97
98 Add the following variables to your system
99
100 {code}
WilliamLesguillier 2.1 101 LANG = en_US.UTF-8
slauriere 1.1 102 {code}
103
104 Credits: http://www.nabble.com/Re%3A-problem-with-Chinese-p9547507.html

Get Connected