Does kivy not support GBK encoding type on android?

17 views
Skip to first unread message

qiaon...@gmail.com

unread,
Jan 1, 2019, 7:43:01 AM1/1/19
to Kivy users support
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: GBK
well 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
Reply all
Reply to author
Forward
0 new messages