I am working on a project where Arabic language is used and I am using pyqt for the same. There is a text box in which I enters in Arabic then take that Arabic in a variable and read it using python. I have tried using UTF-8 as well but didn't worked.
For example I am entering
بسم الله الرحمن الرحيم
in the text box but when I read content of that box, I get the variable something as:
???? ????? ????
If I do not use the Unicode, then it gives me error as
ASCII code cannot encode characters.
How get same print variable in Arabic as entered in box ?
code is :
item=dir(self.listWidget.selectedItems())
item=self.listWidget.currentItem()
content=self.textEdit.toPlainText()
content = unicode(content, "utf-8")
FROMADDR = ""
LOGIN = FROMADDR
PASSWORD = ""
TOADDRS = str(item.text())
SUBJECT = "Invitation"
msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n"
% (FROMADDR, ", ".join(TOADDRS), SUBJECT) )
msg += ((u"%s")%content)#"some text\r\n"
server = smtplib.SMTP('smtp.gmail.com', 587)
server.set_debuglevel(1)
server.ehlo()
server.starttls()
server.login(LOGIN, PASSWORD)
server.sendmail(FROMADDR, TOADDRS, msg)
server.quit()