title: Resolving ascii codec can't decode byte in position ordinal not in range
body: <p>I've seen all of the other posts and done quite a bit of research but I am still scratching my head.</p>
  
  <p>Here is the problem:</p>
  
  <pre><code>$ python
  Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
  [GCC 4.8.2] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; a=u'My Mate\u2019s'
  &gt;&gt;&gt; b='\xe2\x80\x99s BBQ'
  &gt;&gt;&gt; print a
  My Mate’s
  &gt;&gt;&gt; print b
  ’s BBQ
  </code></pre>
  
  <p>So, the variables are finely printed themselves, but printing a concatenation:</p>
  
  <pre><code>&gt;&gt;&gt; print a+b
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128)
  </code></pre>
  
  <p>gives a decode error. So, I try to decode the string:</p>
  
  <pre><code>&gt;&gt;&gt; print a.decode('utf-8')+b.decode('utf-8')
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
      return codecs.utf_8_decode(input, errors, True)
  UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 7: ordinal not in range(128)
  </code></pre>
  
  <p>The error changes into an encode error. So, I try a couple of ways to inform the encoding:</p>
  
  <pre><code>&gt;&gt;&gt; print a.decode('utf-8').encode('utf-8')+b.decode('utf-8').encode('utf-8')
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
      return codecs.utf_8_decode(input, errors, True)
  UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 7: ordinal not in range(128)
  &gt;&gt;&gt; print a.decode('ascii','ignore')+b.decode('ascii','ignore')
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 7: ordinal not in range(128)
  &gt;&gt;&gt; print a.decode('utf-8').encode('ascii','ignore') +b.decode('utf-8').encode('ascii','ignore')
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
      return codecs.utf_8_decode(input, errors, True)
  UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 7: ordinal not in range(128)
  &gt;&gt;&gt; 
  </code></pre>
  
  <p>The error persists no matter what I try.</p>
  
  <p>I suppose the problem might be very simple. I'd appreciate someone helping with an explanation of what's going on, and how to resolve this.</p>
  
  <p>I have python 2.7 on ubuntu.</p>