title: Iterate over utf-8 characters in python
body: <p>I am using python 3.6 to read a file encoded in utf-8, in Spanish (thus, including letter ñ). I open the file with the utf-8 codec, and it loads correctly: while debugging, I can see ñ in the loaded text.</p>
  
  <p>However, when I iterate over characters, ñ is read as two characters, n and ~. Concretely, when I run:    </p>
  
  <pre><code>for c in text:
          hexc = int(hex(ord(c)), 16)
          if U_LETTERS[lang][0] &lt;= hexc &lt;= U_LETTERS[lang][1] \
              or hexc in U_LETTERS[lang][2:] \
              or hexc == U_SPACE:
                  filtered_text+=c
  </code></pre>
  
  <p>and text includes an ñ, the variable c takes it as an n (and therefore, hexc is 110 instead of 241), and then it takes ~ (and hexc is 771). I guess there is an internal conversion to an 8 bit char when iterating in this way.  What is the proper way to do this?</p>
  
  <p>Thanks in advance.</p>