469,934 Members | 1,873 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

Special character errors in XML page

XML gives an error when I have a sign (GBP) - £ - in a string.
I've fixed this by converting it to its HTML number.

In case other characters may cause the same error, I'm converting
characters to their HTML numbers that < 32 or 126 decimal.

Is this correct? What would you advise?

Thanking you in anticipation.
Dec 27 '07 #1
2 2323
withers wrote:
XML gives an error when I have a sign (GBP) - £ - in a string.
I've fixed this by converting it to its HTML number.

In case other characters may cause the same error, I'm converting
characters to their HTML numbers that < 32 or 126 decimal.

Is this correct? What would you advise?
Use an Unicode encoding like UTF-8 and an editor that supports that,
that way you certainly do not have to use numeric character references.
Even if you do not use Unicode you do not have to use numeric character
references for the pound sign, you just need to make sure you use an
encoding that contains that sign and you properly declare that encoding
in the XML declaration and you make sure your editor saves with the
declared encoding.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 28 '07 #2
On Dec 27, 3:32 pm, withers <ro...@upperbridge.co.ukwrote:
XML gives an error when I have a sign (GBP) - £ - in a string.
You must either use an encoding which supports that character (and use
the XML Declaration to tell the processor which encoding you're using,
unless it's UTF8 or UTF16), or use the numeric escape. XML processing
generally uses Unicode internally, so it can handle just about every
character you've ever heard of and many you haven't -- but UTF8
requires characters above 127 be represented by multiple bytes, and of
course UTF16 starts out as a two-byte-per-character encoding.

Characters below space (32) -- the "control characters" -- are flat-
out illegal in XML 1.0. XML 1.1 relaxes this constraint, but is not
yet widely supported. The usual solution, if you must handle these, is
to do a base-64 encoding of your data before putting it into the XML
and reverse that before using it.

See the XML Recommendation for a discussion of which characters can,
and can't, be directly represented in XML. See the UTF8 spec for a
discussion of how its variable-length character encoding works.
Dec 28 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Bal | last post: by
4 posts views Thread by Norman Uhlenkott | last post: by
5 posts views Thread by Martin Eyles | last post: by
20 posts views Thread by SMG | last post: by
8 posts views Thread by Colin Peters | last post: by
2 posts views Thread by Ozer | last post: by
2 posts views Thread by Diilb | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.