I use
network.UrlRequest to retrieve something from a Chinese website which contains Chinese characters. The return value is not encoding with UTF-8, I want do some split and other operates on it, I decode it with GBK first and then encod it with UTF8. these codes runs on windows well but runs failed when I pack to apk run on my android phone. the error message is
exception: unknown encoding: GBKwell I also tried decoding with GB1830 and decoding with UTF8 directly, but they were all failed. the code is below:
Does somebody help me?
def getDataByUrl(self, novalname, search_url):
search = {'searchkey':novalname}
search = urllib.urlencode(search)
newurl = search_url + "?" + search
self.request = UrlRequest(newurl, self.res)
def res(self,*args):
try:
data = self.request.result.decode('GBK').encode('utf8')
except Exception, e:
print 'bbg: exception:', str(e)
bbg: exception: unknown encoding: GBK