title: How to find right encoding in python?
body: <p>I'm trying to get rid of diacritics in my textfile. I converted a pdf to text with a tool, not made by myself. I wasn't able to understand which encoding they use. The text is written in <a href="http://en.wikipedia.org/wiki/Nahuatl" rel="nofollow noreferrer">Nahuatl</a>, orthographically familiar with Spanish.</p>
  <p>I transformed the text into a list of strings. No I'm trying to do the following:</p>
  <pre><code># check whether there is a not-ascii character in the item
  def is_ascii(word):
      check = string.ascii_letters + &quot;.&quot;
      if word not in check:
          return False
      return True
  
  # if there is a not ascii-character encode the string 
  def to_ascii(word):
      if is_ascii(word) == False:
          newWord = word.encode(&quot;utf8&quot;)
          return newWord
      return word
  </code></pre>
  <p>What I want to get is a unicode-version of my string. It doesn't work so far and I tried several encodings like latin1, cp1252, iso-8859-1. What I get is  Can anybody tell me what I did wrong?</p>
  <p>How can I find out the right encoding?</p>
  <p>Thank you!</p>
  <p><strong>EDIT</strong>:
  I wrote to the people that developed the converter (pdf-txt) and they said they were using unicode already. So John Machin was right with (1) in his answer.
  As I wrote in some comment that wasn't clear to me, because in the Eclipse debugger the list itself showed some signs in unicodes, others not. And if I looked at the items seperately they were all decoded in some way, so that I actually saw unicode.</p>
  <p>Thank you for your help!</p>