Results 1 to 7 of 7

Thread: XML + Internet Explorer + Character Encoding = Big Headaches

  1. #1
    Site Contributor KLB's Avatar
    Join Date
    Feb 2006
    Location
    Saco Maine
    Posts
    1,181

    XML + Internet Explorer + Character Encoding = Big Headaches

    Today I found another reason to hate Internet Explorer.

    I've been creating a web based database application for a client and am using some Adobe Spry AutoSuggest AJax functionality to create dynamic drop down lists instead of using traditional HTML select input fields. All was going well, or so I thought. The dynamic fields were working brilliantly in Firefox, Safari and Opera. When I tested in MSIE, I got the error "

    Switch from current encoding to specified encoding not supported. Error processing resource
    All of my searching on the Internet turned up reference that lead me to believe I needed to change the following reference:
    <?xml version="1.0" encoding="iso-8859-1"?>
    to:
    <?xml version="1.0" encoding="UTF-8"?>
    So, naturally I tried the change. Per my normal testing practice, I tested MSIE via the development version of the website, which is housed on an Apache/PHP/MySQL install on my laptop before uploading the change and all appeared to be working just fine.

    Then came one of those dreaded emails from the client that all those beautiful dynamic drop downs were not working on Internet Explorer.








    I tested MSIE again on the development version of the site and everything looked good. Then when I tested the live version of the site, sure enough the drop downs were not working in MSIE. I then tested the live version of the site in Firefox, Safari and Opera and everything was working just fine.



    Naturally I thought I forgot to upload a file and I went through and made sure all of the files were synchronized between the test version and the live version of the website. No luck, things were still broken. I manually requested one of the XML files that is used to generate the drop down list via Internet Explorer and it downloaded just fine with appropriate values. It just seemed that the Spry AJax code wouldn't populate the drop down list.

    I searched and searched and could not find any suggested solutions although there were occasional references to character set encodings.

    Since the rest of the site other than the XML files were using ISO-8859-1 I thought well maybe this was the problem and I needed to figure out why the XML files would generate errors unless they were set to UTF-8.



    I tried adding ISO-8859-1 character encodings to the headers of the XML files via .htaccess the PHP "header()" function (this was redundant, but I wanted to be sure) I then reverted back to:
    <?xml version="1.0" encoding="iso-8859-1"?>
    Of course when I did this, MSIE would no longer open the XML file and would instead give me that utterly useless error message. I then requested the XML file in Firefox, which opened it just fine like it had all along. Then I looked at the page info.....





    @#*@!L#* @#(@&$# ###$****!!!!


    When the XML file was opened in Firefox and I looked at the page info, Firefox was telling me that the page encoding was UTF-8.

    Yes, I had declared the character encoding in three different ways to be ISO-8859-1 but Firefox was reporting that it was UTF-8.

    I opened the the php file that generated the XML for the drop down lists in Windows Notepad and did a "Save As" to see what encoding was used when the file was saved. It should have been saved using ANSI, but no it was saved as UTF-8. Apparently the normal text editor had at some point had started converting my files over to UTF-8 when they were saved. Either that or it started creating new files as UTF-8. There is no way of knowing.

    As soon as I resaved all of the files that are used to generate the various XML files for my dynamic drop downs using ANSI encoding via Windows Notepad and then uploaded the files to the webserver, drop downs on the live version of the site started working correctly in Internet Explorer and Firefox was reporting that the character encoding was ISO-8859-1 as it should have been.

    I wasted a huge section of my day trying to track down a really obscure issue, simply because in one detail Internet Explorer is absolutely unforgiving in a most bizarre way. What really blows my mind is why the drop downs would work correctly in MSIE on the Apache/PHP install on my Windows based laptop, but would utterly fail on the Apache/PHP install on the FreeBSD server the live site is hosted on. This is absolutely illogical in the most extreme.

    In over 13 years of website development experience, this has to go down as just about the most bizarre, illogical and frustrating web browser incompatibility issues I have come across. It is also another reason why I hate MSIE.

    ---Footnote---
    If you come across this post searching for why you are getting the error:
    Switch from current encoding to specified encoding not supported. Error processing resource
    Open the text files that house the code you use to generate your XML files in Windows Notepad and then go to save as. Make a note of what encoding Notepad wants to save the file using and make sure this is compatible with the encoding you have declared in the XML declaration. E.g.:
    <?xml version="1.0" encoding="UTF-8"?>
    Unless you have really overwhelming need to support multiple languages and/or non-Latin character sets, I strongly recommend you save all files as "ANSI" and use a non-UTF character set like ISO-8859-1. It will just make your life simpler.
    Ken Barbalace - EnvironmentalChemistry.com (Environmental Careers, Blog)
    InternetSAR.org: Volunteers Assisting Search and Rescue via the Internet
    My Firefox Theme Classic Compact: Based onFirefox's classic theme but uses much less window space

  2. #2
    Administrator Chris's Avatar
    Join Date
    Feb 2003
    Location
    East Lansing, MI USA
    Posts
    7,048
    I hate that IE8 sucks even worse than IE7.
    Chris Beasley - My Guide to Building a Successful Website[size=1]
    Content Sites: ABCDFGHIJKLMNOP|Forums: ABCD EF|Ecommerce: Swords Knives

  3. #3
    Site Contributor KLB's Avatar
    Join Date
    Feb 2006
    Location
    Saco Maine
    Posts
    1,181
    Here's another reason to hate IE. If you are using UTF-8 the UTF-8 BOF bit throws IE into quirks mode even if the entire webpage validates to HTML specifications and the doc type is the very first thing in the file. How stupid is that?
    Ken Barbalace - EnvironmentalChemistry.com (Environmental Careers, Blog)
    InternetSAR.org: Volunteers Assisting Search and Rescue via the Internet
    My Firefox Theme Classic Compact: Based onFirefox's classic theme but uses much less window space

  4. #4
    Site Contributor KLB's Avatar
    Join Date
    Feb 2006
    Location
    Saco Maine
    Posts
    1,181
    I just love it when I'm working on resolving an issue by searching Google and Google sends me back to my own thread that I started months earlier on the subject. Man I'm going in circles.
    Ken Barbalace - EnvironmentalChemistry.com (Environmental Careers, Blog)
    InternetSAR.org: Volunteers Assisting Search and Rescue via the Internet
    My Firefox Theme Classic Compact: Based onFirefox's classic theme but uses much less window space

  5. #5
    Administrator Chris's Avatar
    Join Date
    Feb 2003
    Location
    East Lansing, MI USA
    Posts
    7,048
    But the good thing is... this site ranks well.
    Chris Beasley - My Guide to Building a Successful Website[size=1]
    Content Sites: ABCDFGHIJKLMNOP|Forums: ABCD EF|Ecommerce: Swords Knives

  6. #6
    Site Contributor KLB's Avatar
    Join Date
    Feb 2006
    Location
    Saco Maine
    Posts
    1,181
    Quote Originally Posted by Chris View Post
    But the good thing is... this site ranks well.
    Fortunately for me. I forgot I had already been down this path before. Finding this thread saved me from repeating what I did above.
    Ken Barbalace - EnvironmentalChemistry.com (Environmental Careers, Blog)
    InternetSAR.org: Volunteers Assisting Search and Rescue via the Internet
    My Firefox Theme Classic Compact: Based onFirefox's classic theme but uses much less window space

  7. #7
    Junior Registered
    Join Date
    Aug 2010
    Posts
    1

    Arrrrgghhhh

    This is frustrating isn't it!!

    I hit the same kind of problem, I tried the solutions you mention, but they didn't work.

    Eventually the solution I found that worked with both IE and other browsers was to declare the content type as utf-8 in php

    Code:
    header('Content-Type: text/xml, charset=utf-8');
    and have the XML the php generates also declared as utf-8

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    I just couldn't get ISO-8859-1 to work.

    Many thanks for your post, I'm sure it greatly reduced the amount of time I spent banging my head against the wall and muttering expletives about Microsoft.

    Tim

Similar Threads

  1. Firefox vs. Internet Explorer HELP!!!
    By TLH Solutions in forum HTML, CSS, Layout, and Design
    Replies: 5
    Last Post: 06-04-2008, 09:43 AM
  2. Internet Explorer Vs Firefox
    By Deena in forum General Promotion
    Replies: 5
    Last Post: 12-30-2007, 02:54 PM
  3. email I got from MoveOn.org
    By demosfen in forum Internet Industry News
    Replies: 7
    Last Post: 04-22-2006, 11:46 AM

Bookmarks

Posting Permissions

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