Cannot split a unicode string without converting to ascii - python 2.7
<p>I want to split the string <code>I have Â£300</code> but it seems that the split function first converts it to a ascii and after. But I can't convert it back to unicode the same as it was before. </p>

<p>Is there any other way to split such a unicode string without breaking it as in the snippet bellow.</p>

<pre><code># -*- coding: utf-8 -*-
mystring = 'I have Â£300.'
alist = mystring.split()
alist = [item.decode("utf-8") for item in alist]
print "alist",alist
print "mystring.split()",mystring.split()

#I want to get [I,have,Â£300]
#I get: ['I', 'have', '\xc2\xa3300.']
</code></pre>

<p>The problem is not with <code>split()</code>. The real problem is that the handling of unicode in python 2 is confusing.</p>

<p>The first line in your code produces a string, i.e. a sequence of bytes, which contains the utf-8 encoding of the symbol <code>Â£</code>. You can confirm this by displaying the <code>repr</code> of your original string:</p>

<pre><code>&gt;&gt;&gt; mystring
'I have \xc2\xa3300.'
</code></pre>

<p>The rest of the statements just do what you would expect them to with such input. If you want to work with unicode, create a unicode string to start with:</p>

<pre><code>&gt;&gt;&gt; mystring = u'I have Â£300.'
</code></pre>

<p>A far better solution, however, is to switch to Python 3. Wrapping your head around the semantics of unicode in python 2 is not worth the effort when there's such a superior alternative.</p>

python python-2.7 unicode split non-ascii-characters