[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Encoding Issues with JavaScript in CDATA Element

Subject: Encoding Issues with JavaScript in CDATA Element
From: "Brook Ellingwood" <belling@xxxxxxx>
Date: Wed, 25 May 2005 18:20:35 -0700
javascript change encoding
I have an existing HTML page with a JavaScript in it that includes a variable
that uses the UTF-8 character for the "degree" sign:

var Array_L_Synth = new Array(
//"(Opts[2], 'ChooseTemp', true, true)",
"(fieldSpacer, 'ChooseTemp', true, true)",
"('100 F or below', 'L_Synth_10')",
"('150 F to 320 F', 'L_Synth_15')",
"('350 F and above', 'L_Synth_35')"
);

This page has no problems.

I copied the JavaScript into a CDATA element in an XML file:

<script><![CDATA[
 <script type="text/javascript">
...
 ]]></script>
</script>

I applied this template:

<xsl:template match="script">
 <xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:template>

I'm using XMLSpy/MSXML 3. IE displays the output fine, but Firefox and Opera
both have problems with the "degree" character, and the source shows the
problem as well:

var Array_L_Synth = new Array(
//"(Opts[2], 'ChooseTemp', true, true)",
"(fieldSpacer, 'ChooseTemp', true, true)",
"('10B0 F or below', 'L_Synth_10')",
"('15B0 F to 32B0 F', 'L_Synth_15')",
"('35B0 F and above', 'L_Synth_35')"
);

If I manually change the browser encoding from ISO-8859-1 to UTF-8, the
problem resolves itself. However if I go to the orinal HTML (which displays
fine) and change the browser encoding to UTF-8, the properly rendered "degree"
signs turn into "?".

I can't figure this one out. Any ideas?

I'm using the exact same XML/XSL on two other JavaScripts that don't have any
problems. It's not impossible for me to make this an external .js file if that
will solve the problem, but I don't know if that will fix it and I'm
interested in understanding what's going wrong.

Thanks,
-- Brook

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.