[TIMOB-9411] Android:Network:createHttpClient cannot handle Japanese Shift_JIS and EUC-JP encoding
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2012-06-06T10:02:38.000+0000 |
Affected Version/s | Release 2.1.0 |
Fix Version/s | n/a |
Components | Android |
Labels | api, qe-and060112, regression |
Reporter | Shyam Bhadauria |
Assignee | Neeraj Gupta |
Created | 2012-06-06T03:45:06.000+0000 |
Updated | 2017-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();
}
Closing ticket as duplicate.