title: Python: for-iteration through a utf-8 string -> what's the data type/encoding of the iterators?
body: <p>I have a utf-8 encoded strings(mainly Chinese + some english), and want to run a letter count on them. (similar to English word count). </p>
  
  <p>So I used</p>
  
  <pre><code>for letter in text:    # text is a utf-8 encoded str
  </code></pre>
  
  <p>but I'm not sure what I'm getting as a 'letter'. 'text' print in screen fine and write to csv fine. But the 'letter' in 'for letter in text' looks all crashed both on screen and in csv file. I think it's definitely some problem related with encoding, but adding <code>.encode('utf-8')</code> here and there doesn't solve the problem and returns error like</p>
  
  <pre><code>UnicodeDecodeError: 'ascii' codec can't decode byte 0x83 in position 0: ordinal not in range(128)
  </code></pre>
  
  <p>What I mean is the code below doesn't return error but the letters look all crashed, and it returns the above error message when I add .encode('utf-8') to 
  print <code>letter.encode('utf-8')</code> or <code>wcwriter.writerows([[k.encode('utf-8'), v]])</code></p>
  
  <pre><code># -*- coding: utf-8 -*-
  ...
  
  with open(fname+'.csv', 'wb') as twfile:
      twwriter = csv.writer(twfile)
      twwriter.writerows([[u'Date/Time', u'Text', u'ID', u'Location', u'City', u'Province']])
  
      for statuses in jres.get('statuses'): # jres is a json format response returned from a API call request
          text = statuses.get('text').encode('utf-8')
  
          if keyword in text:
              td = statuses.get('created_at').encode('utf-8')
              name = statuses.get('user').get('screen_name').encode('utf-8')
              loc = statuses.get('user').get('location').encode('utf-8')
              city = statuses.get('user').get('city').encode('utf-8')
              province = statuses.get('user').get('province').encode('utf-8')
  
              twwriter.writerows([[td, text, name, loc, city, province]])
              keycount += 1
  
  # this is the problematic part. I'm not sure exactly what data type or encoding I'm getting for 'letter' below 
  
              for letter in text:
                  if letter not in dismiss:
                      print letter   # this will print a lot of crushed letters
                      if letter not in wordcount:
                          wordcount[letter] = 1
                      else:
                          wordcount[letter] += 1
  
  with open(wcname+'.csv', 'wb') as wcfile:
      wcwriter = csv.writer(wcfile)
      wcwriter.writerows([[u'Letter', u'Number']])
  
      for k, v in wordcount.items():
          wcwriter.writerows([[k, v]])
  </code></pre>