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

Re: character encoding in xsl [forced]

Subject: Re: character encoding in xsl [forced]
From: Mike Brown <mike@xxxxxxxx>
Date: Mon, 2 Dec 2002 15:53:10 -0700 (MST)
xsl character encoding
Mac Rost wrote:
> I am having a pblm with the character encoding of a nbsp; in my xsl.

You have 2 problems, actually.

> When the html transformation is done, each nbsp; comes out as a ?.

This is problem #1. If you ever see a character replaced with "?", it means
that you tried to serialize it in an encoding that did not have a byte
sequence available to represent that character. If it's a no-break space,
which is Unicode character #160 (#xA0), the most likely cause is that you were
trying to encode it as us-ascii, which only covers Unicode characters #0-#127.

I suspect that this problem is unrelated to the second problem.

> Now when the transformation is finished, the encoding is set to utf-16.
> Is there a way to force a different encoding?

Problem #2. In general, you can tell the XSLT processor what encoding to use
*if* it is serializing the output via the encoding attribute of the xsl:output
element. That is, use <xsl:output method="..." encoding="utf-8"/> in your
stylesheet.

Ensure that the input to the XSLT processor (both XML and XSLT) are either
Unicode text or encoded text with an accurate encoding declaration in their 
XML prologs.

If the result is being serialized as encoded text, ensure that the xsl:output
instruction tells the XSLT processor what encoding you want it to use.

Ensure that the result of the transformation is not being coerced to a
different encoding (UTF-16, it seems) when you pass it around within your
application. For example, if you're getting a Microsoft DOM object as the
result, and you're capturing it in a String object, you'll get UTF-16 during
the implicit conversion. If you're using MSXML and think this might be
happening, do a Google search for MSXML UTF-16 and you'll find the answer.

Mike

-- 
  Mike J. Brown   |  http://skew.org/~mike/resume/
  Denver, CO, USA |  http://skew.org/xml/

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


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.