Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2901] Android: Titanium.Network.responseXML string is garbled characters when charset is not utf-8

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionFixed
Resolution Date2012-07-26T16:38:05.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsapi
ReporterSatoshi Tanaka
AssigneeDavide Cassenti
Created2012-07-19T22:11:55.000+0000
Updated2016-03-08T07:47:52.000+0000

Description

Overview

The result of Titanium.Network.responseXML string is garbled characters when charset is not utf-8.

Sample Code

I make sample xml (charset is Shift_JIS) on my website.
var xhr = Titanium.Network.createHTTPClient();
xhr.open('GET','http://kangaechu.com/xml/shiftjis.xml');
//xhr.open('GET','http://kangaechu.com/xml/utf-8.xml');

xhr.onload = function(){
    //Ti.API.info(this.responseText);
    var titles = this.responseXML.getElementsByTagName('title');
    Ti.API.info(titles.length);
    for (var i=0; i<titles.length; i++){
    	Ti.API.info(i + " : " + titles.item(i).textContent);
    }
};

xhr.onerror = function(error){
	Ti.API.error(error.toString());
};
xhr.send();

Result

Excepted: {quote} I/TiAPI ( 1844): 0 : hello I/TiAPI ( 1844): 1 : こんにちわ {quote} Result: {quote} I/TiAPI ( 1963): 0 : hello I/TiAPI ( 1963): 1 : 縺薙s縺ォ縺。繧� {quote}

Comments

  1. Satoshi Tanaka 2012-07-19

    Created PR #2616 to resolve issue. https://github.com/appcelerator/titanium_mobile/pull/2616
  2. Shak Hossain 2013-12-28

    https://github.com/appcelerator/titanium_mobile/pull/2616 was merged.

JSON Source