tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Markus Schönhaber <mailing-tomcat-u...@schoenhaber.de>
Subject Re: getting "?" instead of "¢"
Date Mon, 17 Jul 2006 11:56:05 GMT
David Delbecq wrote:
> This is not a matter of saving the jsp/html file on server with the good
> charset, 

It is.

> this is a matter of using the correct entity reference (&cent;) 
> which is supposed to be displayable by any html 2.0 compliant browser.

Using an entity reference is just one way to get "special" characters 
transmitted to the client. But this will only work if this entity reference 
is defined/recocgnized/interpreted in the output format used - for example in 
HTML. For other output formats - for example plain text - this will obviously 
be useless.
Since - in my experience - modern clients on modern OSes can handle correctly 
encoded input just fine (if they are told how it's encoded), I see no general 
need to cope with entity references. It all boils down to the fact that the 
encoding declared in the HTTP header and the encoding actually used have to 
match.

So I'd also stick with Ronald's proposal and create correctly encoded output.

The following - if saved as UTF-8 - should work as expected:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Display a cent</title>
</head>
<body>
<p>These are two cents: ¢ &cent;
</body>
</html>

BTW: it isn't strictly neccessary to use UTF-8. Using a charset that contains 
all symbols used is enough. This mail for example should use ISO-8859-1 as 
charset and still contain the literal cent sign above correctly encoded.
Nevertheless I'd prefer UTF-8 on the web as a more universal approach.

Regards
  mks

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message