Special character errors in XML page

Discussion in 'XML' started by withers, Dec 27, 2007.

  1. withers

    withers Guest

    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.
     
    withers, Dec 27, 2007
    #1
    1. Advertising

  2. 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/
     
    Martin Honnen, Dec 28, 2007
    #2
    1. Advertising

  3. withers

    keshlam Guest

    On Dec 27, 3:32 pm, withers <> wrote:
    > 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.
     
    keshlam, Dec 28, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Goldin

    Errors, errors, errors

    Mark Goldin, Jan 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,031
    Mark Goldin
    Jan 17, 2004
  2. =?Utf-8?B?UHVzaHBlbmRyYQ==?=

    Error reading special character '{' hexadecimal value 0x7B in xml

    =?Utf-8?B?UHVzaHBlbmRyYQ==?=, Jul 24, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    4,665
    Shan Plourde
    Jul 27, 2004
  3. KFC
    Replies:
    1
    Views:
    671
  4. Replies:
    1
    Views:
    921
    Roedy Green
    Oct 27, 2005
  5. Replies:
    1
    Views:
    1,497
    Peter Flynn
    Jan 8, 2005
Loading...

Share This Page