中国的网站总是使用gbk charset。我试图从网站获取数据:
var url = "http://nga.178.com/thread.php?fid=7";
var client = Ti.Network.createHTTPClient({
// function called when the response data is available
onload : function(e) {
Ti.API.info("Received text: " + this.responseText);
alert('success');
},
// function called when an error occurs, including a timeout
onerror : function(e) {
Ti.API.debug(e.error);
alert(e.error + client.status);
Ti.API.debug(client.responseText);
},
timeout : 50000 // in milliseconds
});
// Prepare the connection.
client.open("GET",url);
// Send the request.
client.send();
但是回复:
[DEBUG] : <title>ÌáʾÐÅÏ¢</title>