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

RE: UTF-16 -> UTF-8

  • From: Michael Brennan <Michael_Brennan@a...>
  • To: "Ollikainen, Jari" <Jari.Ollikainen@q...>
  • Date: Tue, 26 Jun 2001 13:42:51 -0700

utf 16 to utf 8
You have to watch out for the interactions with ASP, though. ASP has it's
own way of dealing with character encodings that is completely independent
of the XML technologies.

The key thing to watch out for is the Response.Write method. It always
abides by the "codepage" in effect, which is typically some variant of one
of the ISO-8859 set of encodings. To change this, you can explicitly set the
codepage and Content-Type header to do the right thing:

<%
	Session.Codepage=65001
	Response.ContentType = "text/xml; charset=UTF-8"
	...
%>

Alternatively, avoid using Response.Write. The "save" method on Microsoft's
DOM Document object ignores the ASP codepage and always uses UTF-8 (and sets
the Content-Type header for you) if you use the ASP Response object as the
parameter to that method. Likewise, if using XSLT, use the
"transformNodeToObject" method to invoke the stylesheet, and specify the
Response object as the second parameter, rather than using "transformNode"
in conjunction with Response.Write.

In deference to those who have chastised me in the past for responding to
Microsoft-specific questions on this list: if you have further questions,
you may want to ask in one of the Microsoft-specific newsgroups (such as
microsoft.public.xml or microsoft.public.xsl, which are publicly accessible
on the server msnews.microsoft.com).


> -----Original Message-----
> From: Bob DuCharme [mailto:bob@u...]
> Sent: Tuesday, June 26, 2001 10:51 AM
> To: Ollikainen, Jari; xml-dev
> Subject: Re: UTF-16 -> UTF-8
> 
> 
> > I have a problem where my DB is stored as UTF-16 but as I'm using
> asp-pages
> > I need to change charset code to UTF-8. How can I do this? 
> Using XSLT or
> > what?
> 
> It's pretty simple in XSLT; just set the encoding attribute of the
> xsl:output element. Below is an identity stylesheet that 
> writes its output
> as UTF-8. Keep in mind that not all XSLT processors can write to all
> encodings, but they are supposed to give you an error message 
> if they can't
> handle the setting of the encoding attribute. According to 
> the XSLT Rec,
> they all have to "respect values of UTF-8 and UTF-16," but not all can
> handle UTF-16.
> 
> (In general, the XSL-list at 
> http://www.mulberrytech.com/xsl/xsl-list/ is
> the place where XSLT questions will get the quickest answers.)
> 
> Bob DuCharme            www.snee.com/bob             <bob@
> snee.com>      see http://www.snee.com/bob/xsltquickly for
> info on new book "XSLT Quickly" from Manning Publications.
> 
> <!-- ~~~~~~~~~~~~~~~~~~~~~ -->
> 
>   <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>       version="1.0">
> 
>   <xsl:output encoding="utf-8"/>
> 
>   <xsl:template match="@*|node()">
>     <xsl:copy>
>       <xsl:apply-templates select="@*|node()"/>
>     </xsl:copy>
>   </xsl:template>
> 
>   </xsl:stylesheet>
> 

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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.