title: How to convert Arabic text from PyQt4 to UTF-8
body: <p>I made a Python 2 GUI application with PyQt4 that has two entries. The first takes the file name, and the second takes the text to write in the file.</p>
  
  <p>I want to enter Arabic text in both of them, so I wrote this function:</p>
  
  <pre><code>def makefile(self):
      self.name_file=str(self.lineEdit.text()).decode("utf-8")
      self.string=str(self.lineEdit_2.text()).decode("utf-8")
      file=open(self.name_file,"w")
      file.write(self.string)
      file.close()
  </code></pre>
  
  <p>When I enter English letters it works fine, but when I enter Arabic I get the following error:</p>
  
  <blockquote>
    <p>UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)</p>
  </blockquote>