Special character errors in XML page

W

withers

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.
 
M

Martin Honnen

withers said:
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.
 
K

keshlam

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top