File: charsets.html

package info (click to toggle)
sitemesh 2.4.1%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 1,816 kB
  • sloc: java: 6,707; xml: 514; jsp: 393; perl: 64; makefile: 11; sh: 9
file content (71 lines) | stat: -rw-r--r-- 3,202 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<html>
	<head>
		<title>SiteMesh and Charsets</title>
	</head>
	
	<body>
		<h3>Platform Defaults</h3>
		
		<p>The default character set for SiteMesh is iso-8859-1. SiteMesh 
		currently assumes that the underlying platform encoding is also iso-8859-1.</p>
		
		<p>This can cause some fairly insidious problems if there is a 
		mismatch between the two! Specifically, on platforms which have a 
		different file encoding, this should be overridden. The two known 
		platforms which do not have iso-8859-1 encoding by default are IBM 
		AS/400 JDK's and OSX. The work around in these cases is to specify a 
		<code>-Dfile.encoding=iso-8859-1</code> parameter as JVM argument when 
		starting the application server. </p>
		
		<h3>Using Other Encodings</h3>
		
		<p>The iso-8859-1 encoding is sufficient for most European and Western 
		character sets, so nothing will need to be done in this case. However, 
		for other languages that require the full range of the UTF-8 character 
		set, this has to be explicitly specified at a number of places, some 
		SiteMesh specific, some app server specific/jsp specific.</p>
		  
		<p>Note that the examples below all refer to UTF-8. The same approach 
		applies to any encoding other than iso-8859-1, and is not limited to 
		UTF-8.</p>
		
		<p><b>1.</b> If possible, the web application should be configured to 
		use UTF-8 as the default encoding. Orion allows this to be specific in 
		orion-web.xml, as the <code>default-charset</code> attribute. Weblogic 
		requires a context parameter named 
		<code>weblogic.httpd.inputCharset</code>. See your application server 
		documentation for more details. If the application server of choice does 
		not allow to set the default charset for all web-apps, then every page 
		(including the decorators) will need to specify the content-type. This 
		is done by specifying a page header tag like this:</p>
		
<pre style="border: 1px solid #999999; padding: 5px">
&lt;%@ page contentType=&quot;text/html; charset=<b>utf-8</b>&quot;%&gt;
</pre>

        <p>Note that some older versions of Orion do not respect the contentType 
        page directive in included pages, so to be on the safe side, this 
        directive should be specified in ALL pages, not just the top level one 
        (one could use an include).</p>
		    
        <p><b>2.</b> The next step is to inform the browser that the page contents are of 
        a specific character set. This is done by specifying a meta tag in the 
        HEAD element of the html page, like this:
        
<pre style="border: 1px solid #999999; padding: 5px">
&lt;META HTTP-EQUIV=&quot;content-type&quot; CONTENT=&quot;<b>text/html; charset=utf-8</b>&quot;&gt;
</pre>

        <p><b>3.</b> The final step is informing SiteMesh's decorator mechanism that it 
        should use a specific encoding other than the default. This is done by 
        specifying an encoding attribute to the applyDecorator tag with the name 
        of the encoding to use.</p>		  

<pre style="border: 1px solid #999999; padding: 5px">
&lt;page:applyDecorator name=&quot;form&quot; encoding=&quot;<b>utf-8</b>&quot;&gt;
    ...
&lt;/page:applyDecorator&gt;
</pre>
	
	</body>
</html>