Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-1672] Android: XHR to XML (responseXML) does not respect encoding

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:56:49.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.5.0
ComponentsAndroid
Labelsandroid, defect
ReporterBill Dawson
AssigneeBill Dawson
Created2011-04-15T02:59:01.000+0000
Updated2011-04-17T01:56:49.000+0000

Description

Customer uses a feed service which provides xml in ISO-8859-1. The xml processing instruction accurately reflects that the charset=ISO-8859-1. Our HTTPClient.responseText also accurately determines the charset, but HTTPClient.responseXML just hands off the string to XMLModule.parse without telling it what the encoding is.

In the customer's specific case, this meant that umlauts (e.g., ö) and accented characters (e.g., é) were screwed up when displayed on the android (or emulator) screen.

Screenshot of problem:

http://skitch.com/billdawson/dwk1r/5560-titanium-5-hvga">http://skitch.com/billdawson/dwk1r/5560-titanium-5-hvga

Attachments

FileDateSize
emulator.png2011-04-15T02:59:01.000+0000119408
remotefile.js2011-04-15T02:59:02.000+00006789
titanium.png2011-04-15T02:59:01.000+0000148157

Comments

  1. Bill Dawson 2011-04-15

    Test case (see me via e-mail for the URL for xhr.open() -- it's not to be made public).

       
       var win = Titanium.UI.createWindow({  
           title:'Drivers',
           backgroundColor:'#fff',
           fullscreen: true,
           exitOnClose: true
       });
       
       win.open();
       
       var rows = [];
       var xhr = Ti.Network.createHTTPClient();
       xhr.onload = function(e) {
           try {
               var xml = xhr.responseXML;
               if (xml) {
                   var session = xml.getElementsByTagName('session');
                   if (session) {
                       session = session.item(0);
                   } else { 
                       alert('session list not fetched');
                       return;
                   }
                   if (session) {
                       if (!session.hasChildNodes()) {
                           alert('No child nodes');
                           return;
                       }
                       var length = session.childNodes.length;
                       for (var i = 0; i < length; i++) {
                           var child = session.childNodes.item(i);
                           if (child.nodeType == child.ELEMENT_NODE) {
                               rows.push(Ti.UI.createTableViewRow({color: 'black', title: child.getAttribute("driver")}));
                           }
                       }
                       win.add(Ti.UI.createTableView({data: rows}));
                   } else {
                       alert('"session" not found');
                   }
               } else {
                   alert('XML did not load');
               }
           } catch(ex) {
               alert(ex);
           }
       };
       xhr.open('GET', '(SEE BILL FOR URL -- IT IS NOT TO BE MADE PUBLIC)');
       xhr.send();
       

    Screenshot when fixed:
    http://skitch.com/billdawson/dwk16/5560-titanium-5-hvga">http://skitch.com/billdawson/dwk16/5560-titanium-5-hvga

  2. Jeff Haynie 2011-04-15

    (from [5a5703997aa24b161599439e25ca4c5fce0f3e80]) [#1672 state:fixed-in-qa] XHR now respects encoding when passing string to XMLModule.parse for responseXML http://github.com/appcelerator/titanium_mobile/commit/5a5703997aa24b161599439e25ca4c5fce0f3e80"> http://github.com/appcelerator/titanium_mobile/commit/5a5703997aa24...

  3. Bill Dawson 2011-04-15

    Actually you can get the feed address from the problem description in helpdesk ticket 38891.

  4. marco.schierhorn (at gmail) 2011-04-15

    Hey Bill,

    thanks a lot for your help again. I have attached 2 screenshots bcs im still having the "umlaut" issue. And im using the build from your continous build server.

    Maybe its because im downloading the file and save it into another file. I have also attached the js file which handles the downloading and saving of the file. And im using responseData instead of responseXML.

    Best regards, Marco

  5. marco.schierhorn (at gmail) 2011-04-15

    Here is the remoteFile.js File

  6. Bill Dawson 2011-04-15

    Hi Marco,

    Please add to your helpdesk ticket instead of here. The issue described by the title of this lighthouse ticket really is resolved, so we should carry on with other problems (i.e., going through a file) via helpdesk.

    thank you,
    Bill

  7. Thomas Huelbert 2011-04-15

    confirmed

JSON Source