tags:

views:

393

answers:

4

I'm reading a data source, and then applying an xsl transform to the text that comes out and all the £ and € symbols are being stripped.

Am I missing something obvious? I've tried changing the encoding to iso-8859-1 to no avail.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
    <xsl:output encoding="utf-8"/>
    <xsl:output method="html" omit-xml-declaration="yes"/>
    <xsl:param name="Subject"/>
    <xsl:param name="DateString"/>
    <xsl:param name="CurrentSiteUrl"/>

    <xsl:template match="/">
     <html>
      <xsl:apply-templates/>
    </html>
    </xsl:template>
    <xsl:template match="posts>
     <xsl:variable name="postcount" select="count(content)"/>
     <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html;utf-8" />
      </head>
+4  A: 

Easiest way will be to use character entities.

&#163; for £ &#8364; for €

(Hmm... markdown needs double escapes!)

Richard
A: 

try using &eur; and &#163; to output those symbols.

axel_c
only works in HTML, not XML (at least not without a DTD).
Richard
A: 

Am I missing something obvious? I've tried changing the encoding to iso-8859-1 to no avail.

That won't work as ‘€’ isn't in iso-8859-1

<xsl:output encoding="utf-8"/>
<xsl:output method="html" omit-xml-declaration="yes"/>

just a hunch but could you do

<xsl:output method="html" omit-xml-declaration="yes" encoding="utf-8"/>

I don't know if the attributes of xsl:output are concatinated or overridden.

You will probably find that the entities come out encoded anyways.

Jeremy French
iirc, the euro character exists in iso-8859-15 though, the modern replacement for iso-8859-1.
R. Bemrose
Yep - ISO-8859-15 is the charset for the Euro, but the Euro isn't the only change (so double check you don't need any of the changed characters). Wikipedia's got a summary of the differences at: http://en.wikipedia.org/wiki/ISO/IEC_8859-15
Chris J
A: 

Use £ and € characters directly. That's what UTF-8 is for.

Just make sure you're sending XML files with proper MIME type. Often used text/xml overrides encoding in <?xml ?> declaration!
Configure server to always use application/xml if it doesn't do that yet.

You've got error in HTML encoding declaration. <meta> should contain:
text/html;charset=UTF-8.

porneL