xsl-list
[Top] [All Lists]

RE: silly (c) symbol. How to get © in output ?

2003-04-24 13:52:37
[malcolm macaulay]

In my previous post the first example was supposed to use 
#169; with little 
ampersand in the front.

cheers

Malcolm

Date: Fri, 25 Apr 2003 08:18:32 +1200

I'm having a lot of trouble getting *©* (the copyright 
system) to 
output.

I know this problem has been explained before but I can't 
find the thread 
which has a working answer.

I'm getting this:

<xsl:text disable-output-escaping="yes">©</xsl:text> gives 
the actual (c) 
symbol in the HTML doc which looks like this: © in the 
browser but look OK 
in XMLSpy.


This is a character encoding issue.  The output file is probably in utf-8 
encoding (which Spy is reading just fine), but the browser thinks it is 
receiving something else, probably iso-885901 (i.e., latin-1).  Your character 
takes two bytes in utf-8 but the browser's encoding uses only one byte per 
character, so it displays two characters, neither one being what you wanted.

Either you have to specify the output encoding that the browser is set for, or 
(better) add a <meta> element that tells the browser which encoding you are 
using.  You can find the right syntax for this through Google.  I am assuming 
here that you are outputting HTML.

<xsl:text>&copy;</xsl:text> gives an undefined entity error.

<xsl:text disable-output-escaping="yes">&copy;</xsl:text> gives an 
undefined entity error.


Of course you get that result, xml does not know anything about all those html 
entities for special characters unless you put them in a DTD.  It will work if 
you use a numeric reference like &#169; and a browser will also recognize it.

And you do not need to use d-o-e, either.

Cheers,

Tom P

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list