Displaying the degree symbol using XSLT

D

Dingbat

I am finding that when I use XSLT to display convert XML like this:

<temp units="°C">23</temp>

the resulting HTML displays an extra character in front of the degree
symbol, like this:

23°C

This happens whether I use PHP or ASP so it seems to be
parser-independent. The XSL fragment would be something like:

<xsl:value-of select="@units"/>

Can anyone explain what's going on? I'm trying to develop XML files
containing weather info, and example XSLT to format and display them,
and this is a bit of a speedbump.

The XML displays as expected in IE 6, ie like this:

<temp units="°C">23</temp>

Thanks for any help.

Dingbat
 
D

David Carlisle

That's the UTF8 encoding. So you either need to make sure that you are
serving the file with the http headers declaring utf8 (and make sure
that your browser understands that encoding) or perhaps you want to
output in latin1 or ascii in which case adding
<xsl:eek:utput encoding="iso-8859-1"/> or
<xsl:eek:utput encoding="US-ASCII"/>
probably works (it depends how you are calling xslt, if the final
serialisation is being done by some other application than the xslt
engine, encoding hints on xsl:eek:utput are likely to be ignored)

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,246
Members
46,841
Latest member
WilmerBelg

Latest Threads

Top