Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6922] Android: Network - HTTPClient cannot retrieve non-ascii data

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2012-04-18T10:38:13.000+0000
Affected Version/sRelease 1.7.5, Release 1.8.0.1
Fix Version/sRelease 2.0.2, Release 2.1.0, Sprint 2012-08, Release 1.8.3
ComponentsAndroid
LabelsSupportTeam, api, parity
ReporterFelix Alcala
AssigneePing Wang
Created2011-10-23T13:15:03.000+0000
Updated2012-05-07T16:17:40.000+0000

Description

Problem

When loading some JSON file (UFT-8) from the web and displaying the data, the Non-Ascii-chars text is garbled. See attached screenshot of this problem on 1.7.2 Note that this works fine on iPhone. The Kitchen Sink Demo of XHR has the same problem. It works on the iPhone but fails on Android.

Test case

Ti.UI.setBackgroundColor('#ddd'); 
var win = Ti.UI.createWindow({});

var loadDataButton = Ti.UI.createButton({
  title: "Let's load UTF-8 from the web!", width: 260, top: 50, height: 40
});
win.add(loadDataButton);
loadDataButton.addEventListener('click', function() {
  var test1 = loadFromWeb("http://crossplattformvergleich.dnsalias.org/test.js");  /* file contains in UTF8: { "result" : "áäüÖßÉ?" }  and a comment */
  var test2 = loadFromWeb("http://crossplattformvergleich.dnsalias.org/test2.js");  /* this is a 36-byte file. Appears as 0 bytes on android */
});

function loadFromWeb(url) {
  var asyncRequest = Ti.Network.createHTTPClient();
  asyncRequest.timeout = 30*1000;
  asyncRequest.open("GET", url); 
  asyncRequest.onload = loadCallback;
  asyncRequest.send();
}

function loadCallback() {
  alert(this.responseText);
}

win.open();

Discussions

Q&A: [problem fetching uft-8 content on android](http://developer.appcelerator.com/question/126712/problem-fetching-uft-8-content-on-android#comment-101538)

Attachments

FileDateSize
00000028.png2011-12-29T06:15:44.000+0000163773

Comments

  1. Paul Dowsett 2011-12-29

    Thanks for raising this ticket, Felix. Please note the changes I have made, that were necessary before I could escalate it. Keeping to the [How to Submit a Bug Report](https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report) guide means that your tickets can be escalated more quickly. Hence, all information must be included in the ticket, rather than rely on external sources. Regarding the following, note that a ticket may only describe a single bug. If you have found a second bug, please raise another ticket.
       Also, I found another bug where an UTF-8 file fetched by android is very small (< 50 bytes), then in the callback this.responseText is NULL. On the iPhone, it all works as intended.
       
    I will move this to the main project now. Cheers
  2. Natalie Huynh 2012-05-07

    Tested with 2.0.2.v20120505151714 with Samsung Nexus S 4.0.4

JSON Source