OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] Using entities for me dash problem

[ Lists Home | Date Index | Thread Index ]

In article <BBFB12B2.10A0%subscriber@pezagency.com>,
JCS <subscriber@pezagency.com> 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




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS