# HG changeset patch # User wycc # Date 1302498551 -28800 # Node ID 9bd8e814f7304373546122e4d1ab174f0f1bd9c0 # Parent e5b3d68d0b05554bb5860c5370747c30844ee754 Handle the utf-8 string correctly. diff -r e5b3d68d0b05 -r 9bd8e814f730 nodejs/examples/mce/epg.js --- a/nodejs/examples/mce/epg.js Mon Apr 11 13:08:33 2011 +0800 +++ b/nodejs/examples/mce/epg.js Mon Apr 11 13:09:11 2011 +0800 @@ -170,28 +170,32 @@ EPG.prototype.getList=function(item,func) { var epgsrv = http.createClient(8080, '211.23.50.144'); - var cmd = '{"Protocol":"EPG-CSP","Command":"SearchRequest","ProgramSub":"'+item.Category+'"}'; + for (k in this.maincat[item]) { + sys.puts(k+"--->"+this.maincat[item][k]); + } + var catID = this.maincat[item]['Category']; + sys.puts(catID); + var cmd = '{"Protocol":"EPG-CSP","Command":"SearchRequest","ProgramSub":"'+catID+'"}'; var headers={ 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Host':'211.23.50.144:8080', 'User-Agent':'MadButterfly', - 'Content-Type':'application/x-www-form-urlencoded' + 'Content-Type':'application/x-www-form-urlencoded;charset=utf-8' }; - headers['Content-Length'] = cmd.length; + //headers['Content-Length'] = cmd.length; var request = epgsrv.request('POST', '/IPTV_EPG/EPGService.do?timestamp='+new Date().getTime(),headers); var self = this; - sys.puts("aaaa"); var js = ''; - request.write(cmd); + request.write(cmd,encoding='utf-8'); request.end(); request.on('response', function(res) { - sys.puts("connected"); res.on('data',function (data) { js = js + data; }); res.on('end', function () { - res = JSON.parse(js); + res = JSON.parse(unescape(js)); sys.puts("parsed"); + sys.puts(js); func(); });