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

Re: Using entities for me dash problem


character 8212
In article <BBFB12B2.10A0%subscriber@p...>,
JCS <subscriber@p...> wrote:

>Thanks, I'm aware of this, however, what I *don't* understand because it
>makes no logical sense, is that if I'm transforming XML UTF-8 to UTF-8 my
>declaration should be UTF-8, not something else. What I mean is, if I use
>US-ASCII as an output method to preserve my NCR the declaration in the
>output file should still be UTF-8, not ASCII, because it's NOT ascii but it
>was *translated* using ASCII to preserve the NCR. Does this make sense? What
>is it that *I'm* not getting, because it's very confusing.

If an XML file contains &#8212; this means Unicode character 8212,
which as you know is em-dash.  The encoding of the file is irrelevant
to this: the numbers in character references are always unicode code
points regardless of the file encoding.  The encoding of the file
determines how the characters "&", "#", "8", "2", "1", "2", and ";"
are represented, not what they mean.

Once the XML document is parsed, there will just be the em-dash
character, stored in the program's own internal encoding.  The fact
that it was once represented by a numeric character reference is
forgotten.

When the program comes to output the document, it will have to decide
how to represent it.  If the output encoding can represent the
character (as UTF-8 can), it will probably just output it directly.
If it can't (as ASCII can't) it will have to use a character
reference.  So you can force character references for non-ASCII
characters by specifying ASCII as the output encoding.

Remember that this is just a trick.  If you really want to output the
document as UTF-8, but with non-ASCII characters represented by
character references, then you probably have to write your own code to
do it.  But since ASCII is a subset of UTF-8, any ASCII XML document
can be converted to a UTF-8 version just by manually editing the
encoding declaration.

-- Richard

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.