Mac Terminal Encoding Issues
<p>I have been dealing with an issue regarding the terminal in my Macbook.
I am passing greek words in a python string e.g. </p>

<pre><code>text = 'ÎÎ±Î»Î·Î¼Î­ÏÎ± ÎºÏÏÎ¼Îµ' 
</code></pre>

<p>and every time I try to perform any simple task to it like splitting in spaces the result I get looks like this:</p>

<pre><code>['\xce\x9a\xce\xb1\xce\xbb\xce\xb7\xce\xbc\xce\xad\xcf\x81\xce\xb1',  
'\xce\xba\xcf\x8c\xcf\x83\xce\xbc\xce\xb5']
</code></pre>

<p>The same thing happens when I use the collections.Counter() function as well.</p>

<p>On the other hand when I print the string the output is as expected:</p>

<pre><code>ÎÎ±Î»Î·Î¼Î­ÏÎ± ÎºÏÏÎ¼Îµ
</code></pre>

<p>I tried doing what is mentioned here: <a href="http://stackoverflow.com/questions/7165108/in-osx-lion-lang-is-not-set-to-utf8-how-fix">In OSX Lion, LANG is not set to utf8, how fix?</a> (by changing en_US.UTF-8 to el_GR.UTF-8) without any luck.</p>

<p>Anyone has an idea why that happens and how I can tackle that?</p>

<p>Thank you in advance.</p>

<p>This is not an issue with your terminal, but how Python (2) does things.</p>

<p>Even if you don't perform any task on it, <code>repr</code> will escape any non-ASCII (or non-printable (except space)) characters:</p>

<pre><code>&gt;&gt;&gt; text = 'ÎÎ±Î»Î·Î¼Î­ÏÎ± ÎºÏÏÎ¼Îµ'
&gt;&gt;&gt; text
'\xce\x9a\xce\xb1\xce\xbb\xce\xb7\xce\xbc\xce\xad\xcf\x81\xce\xb1 \xce\xba\xcf\x8c\xcf\x83\xce\xbc\xce\xb5'
</code></pre>

<p>If you try the same thing in Python 3, it'll print normally:</p>

<pre><code>&gt;&gt;&gt; text = 'ÎÎ±Î»Î·Î¼Î­ÏÎ± ÎºÏÏÎ¼Îµ'
&gt;&gt;&gt; text
ÎÎ±Î»Î·Î¼Î­ÏÎ± ÎºÏÏÎ¼Îµ
</code></pre>

<p>Is there any reason why you're using Python 2?</p>

python osx encoding utf-8 terminal