title: printing UTF-8 in Python 3 using Sublime Text 3
body: <p>I have this Python3 code to attempt to read and print from a utf-8 encoded file:</p>
  
  <pre><code>f = open('mybook.txt', encoding='utf-8')
  for line in f:
      print(line)
  </code></pre>
  
  <p>When I build using Sublime Text 3 I get the following error:</p>
  
  <pre><code>UnicodeEncodeError: 'ascii' codec can't encode character '\u2019' in position 18: ordinal not in range(128)
  </code></pre>
  
  <p>However, it works file when I just execute my code in the terminal with python3.</p>
  
  <p>My build configuration is</p>
  
  <pre><code>{
  "cmd": ["/usr/local/bin/python3", "$file"]
  , "selector": "source.python"
  , "file_regex": "file \"(...*?)\", line ([0-9]+)"
  }
  </code></pre>
  
  <p>If I change it to:</p>
  
  <pre><code>f = open('mybook.txt', encoding='utf-8')
  for line in f:
      print(line.encode('utf-8'))
  </code></pre>
  
  <p>Then it does print the utf-8 encoded byte string (I think that's what's happening).</p>
  
  <pre><code>b'Hello\n'
  b'\xc2\xab\xe2\x80\xa2\n'
  b'Goodbye'
  </code></pre>
  
  <p>But I also don't know how to go from this to printing the unicode characters on the screen...</p>
  
  <p>Also, if I try changing this env variable as per <a href="https://stackoverflow.com/questions/34302902/a-python-program-fails-to-execute-in-sublime-text-3-but-success-in-bash">A python program fails to execute in sublime text 3, but success in bash</a> it still doesn't fix it.</p>