Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9411] Android:Network:createHttpClient cannot handle Japanese Shift_JIS and EUC-JP encoding

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionDuplicate
Resolution Date2012-06-06T10:02:38.000+0000
Affected Version/sRelease 2.1.0
Fix Version/sn/a
ComponentsAndroid
Labelsapi, qe-and060112, regression
ReporterShyam Bhadauria
AssigneeNeeraj Gupta
Created2012-06-06T03:45:06.000+0000
Updated2017-03-10T19:13:53.000+0000

Description

It is a regression.This does not occur on 2.0.2 ,2.0.1 and 1.8.2. Titanium.Network.createHttpClient is returning null value if the encoding style of page is Shift-JIS or EUC-JP.It works fine for utf-8 encoding.
var win1 = Ti.UI.createWindow({
    backgroundColor: 'white',
});
var text = Ti.UI.createLabel({
    text: '',
});
win1.add(text);
win1.open();
charsetTest("http://kangaechu.com/utf8.html");
charsetTest("http://kangaechu.com/shiftjis.html");
charsetTest("http://kangaechu.com/eucjp.html");
 
function charsetTest(url){
    var xhr = Ti.Network.createHTTPClient();
     
    xhr.onload = function() {
        if(this.status == 200) {
            var html = this.responseText;
            if(html == null){
                text.text = text.text + url + ' is null.\n\n';
            }
            else if(html.match(/<body>([\s\S]*)<\/body>/)){
                var body = RegExp.$1;
                text.text = text.text + url + body;
            }else{
                text.text = text.text + url + ' is 200, but no body element.\n\n';
            }
        }else{
            text.text = text.text + url + ' status code is ' + this.status + '\n\n';
        }
    };
    xhr.onerror = function() {
        text.text = text.text + url + ' status code is ' + this.status + '\n\n';
 
    };
    xhr.open("GET", url, false);
    xhr.send();
     
}

Comments

  1. Lee Morris 2017-03-10

    Closing ticket as duplicate.

JSON Source