Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    349
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Another INVALID CHARACTER question

    hello,

    I have something weird going on.. I am using this:

    var eventTags = transport.responseXML.getElementsByTagName( 'item' );

    etc... all seemed great until I ran across some xml, out of the hundreds that I've tested that gave me this error:

    An invalid character wa sfound in text content....

    and the issue is this: geh�ren

    here is the encoding being used: <?xml version="1.0" encoding="UTF-8"?>

    I cannot alter the xml. I have to deal with it as it comes in. Is there anyway I can circumvent that error and still get the data? Perhaps offer an over-ride in html / javascript etc.. of course, this is only happening in IE, ff is fine.

    I am asking for UTF encoding, there is latin in the XML --- is there ANY way (without me messing with the xml etc..) that i can still read this data in and act on it?

    thanks
    Last edited by BrightNail; 05-12-2011 at 02:35 AM.

  • #2
    New Coder
    Join Date
    Feb 2010
    Location
    Manchester, UK
    Posts
    69
    Thanks
    0
    Thanked 13 Times in 13 Posts
    First of all, are you really sure that you are using utf-8 ?
    what I understand:
    you got some web file which through Ajax or in similar fashion gets contents of XML file (wherever it would be)

    then you want to use some contents of the xml file ?

    if you are sure that XML file that you read got coding set then the problem lay in your script which must work in different coding

    on your website that you have script on you must set proper coding using appropriate style for the document you use

    for example
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    349
    Thanks
    2
    Thanked 0 Times in 0 Posts
    hmmm. I tried that Meta tag implementation and it didn't work. The xml would still not render in IE.

    So basically IF the xml is created with latin character code set and the reader (browser) is UTF, it errors out???? arghhh. any other way of solving this issue?

    Can I somehow pass with the "transport.responseXML." some sort of flag that tells the xml to render or igore non-utf characters etc...?

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by BrightNail View Post
    hmmm. I tried that Meta tag implementation and it didn't work. The xml would still not render in IE.

    So basically IF the xml is created with latin character code set and the reader (browser) is UTF, it errors out???? arghhh. any other way of solving this issue?

    Can I somehow pass with the "transport.responseXML." some sort of flag that tells the xml to render or igore non-utf characters etc...?
    the xml is not in latin, this is the problem, is in utf-8 and another problems is that probably is invalid utf-8.
    the word is probably 'gehüren' or 'gehören' and you need to use \uxxxx instead of that char in javascript where \uxxxx is the hex code for that char.

    the declaration from xml prolog doesn't force the xml to have that encoding, if the author used another encoding in his editor or when he generate the xml, the xml is invalid.

    best regards

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Posts
    349
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by oesxyl View Post
    the xml is not in latin, this is the problem, is in utf-8 and another problems is that probably is invalid utf-8.
    the word is probably 'gehüren' or 'gehören' and you need to use \uxxxx instead of that char in javascript where \uxxxx is the hex code for that char.

    the declaration from xml prolog doesn't force the xml to have that encoding, if the author used another encoding in his editor or when he generate the xml, the xml is invalid.

    best regards
    Is there a way to encode the input prior to being written into xml.

    The way our system is, the user enters data into a tool. The tool then sends the data to the backend in which it writes out the xml, and plops it into some directory.

    Is there a way to do some javascript testing/scrubbing in that I can do the write thing prior to the xml being generated?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •