decode utf8 to big5

1.4k Views Asked by At

every one,I am trying to send sms by python, I can send it,but I need to send in Chinese, which is big5,I have to decode utf8 to big5,here is my sms python code

trydecode.py

import urllib
import urllib2


def sendsms(phonenumber,textcontent):
    textcontent.decode('utf8').encode('big5')
    url = "https://url?username=myname&password=mypassword&dstaddr="+phonenumber+"&smbody="+textcontent
    req = urllib2.Request(url)
    response = urllib2.urlopen(req)

this code(python2.7) I can send sms in English but in Chinese (big5) got problem,how can I fix it? thank you

1

There are 1 best solutions below

1
Kode.Error404 On BEST ANSWER

I think you forgot to save it to change the variable.

textcontent = textcontent.decode('utf8').encode('big5')