Wiki source code of Encoding

Version 11.10 by AC on 2010/01/20

Show last authors
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.
30
31 #warning("This is Administration --> Presentation then look for Header --> HTTP Meta Information in more recent XWiki default wikis")
32
33 Inside this textbox locate the *Content-type* meta tag and make it look like this, changing the encoding to UTF-8
34 {code:xml}
35 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
36 {code}
37 #warning("This step is not needed if you have the following. Instead that line can be left alone.")
38 {code:xml}
39 <meta http-equiv="Content-Type" content="text/html; charset=$!xwiki.encoding" />
40 {code}
41
42
43 1.1 Hibernate configuration
44 Add the following lines in the <tt>hibernate.cfg.xml</tt> file:
45 {code:xml}
46 <property name="connection.useUnicode">true</property>
47 <property name="connection.characterEncoding">UTF-8</property>
48 {code}
49
50 1.1 MySQL configuration
51
52 It's common practice that the MySQL configuration file, in \*nix systems is located in /etc/mysql/my.cnf
53 {code}
54 [client]
55 default-character-set=utf8
56 [mysqld]
57 default-character-set=utf8
58 character-set-server = utf8
59 collation-server = utf8_general_ci
60 {code}
61
62 1.1 Servlet Container
63
64 1.1.1 Jetty
65
66 {code}
67 echo off
68 rem set LANG=fr_FR.ISO8859-1
69 set LANG=en_US.UTF-8
70 set JETTY_PORT=8080
71 set JETTY_HOME=.
72 java %JAVA_OPTS% -Djetty.port=%JETTY_PORT% -Djetty.home=%JETTY_HOME% -Dfile.encoding=UTF-8 -jar %JETTY_HOME%/start.jar
73 {code}
74
75 Instead of config system variable LANG you can use JVM properties
76
77 {code}
78 -Duser.language=en
79 -Duser.country=US
80 {code}
81
82 in server startup script.
83
84 1.1.1 Tomcat
85
86 In order to enable UTF-8 in tomcat, you have to add
87
88 {code}
89 URIEncoding="UTF-8"
90 {code}
91
92 to each connector enabled/used in *conf/server.xml*.
93 For example the non-SSL HTTP Connector should read:
94
95 {code:xml}
96 <Connector port="8080" maxHttpHeaderSize="8192"
97 maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
98 enableLookups="false" redirectPort="8443" acceptCount="100"
99 connectionTimeout="20000" disableUploadTimeout="true"
100 URIEncoding="UTF-8"/>
101 {code}
102 #warning("In case you're using AJP to connect Tomcat and httpd, make sure you add this attribute to the AJP connector.")
103
104 1.1.1 [Glassfish>http://www.glassfish.org/]
105
106 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.
107 First, in the Administration GUI under Domain => General => Locale enter en_US.UTF-8.
108
109 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
110 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.
111
112 Create a new directory that we will use as a temporary place to edit our war file
113 {code}mkdir xwikitmp{code}
114 Unpack the warfile:
115 {code} cd xwikitemp;jar xvf ../xwiki-enterprise-web-1.5.war{code}
116 Edit the files as mentioned in the beginning of this article:
117 * wiki.cfg
118 * web.xml
119 * hibernate.cfg.xml
120 Now lets create a new warfile which contains all the changes:
121 {code}jar cvf ../xwiki-enterprise-web-local-1.5.war .{code}
122
123 Now you can deploy your new .war file to Glassfish and it will have all the changes in it and wll be correctly deployed.
124
125
126 1.1 System config
127
128 Add the following variables to your system
129
130 {code}
131 LANG = en_US.UTF-8
132 {code}
133
134 Credits: http://www.nabble.com/Re%3A-problem-with-Chinese-p9547507.html

Get Connected