Python 3 and b'\x92'.decode('latin1')
<p>I'm getting results I didn't expect from decoding b'\x92' with the latin1 codec. See the session below:</p>

<pre><code>Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32
&gt;&gt;&gt; b'\xa3'.decode('latin1').encode('ascii', 'namereplace')
b'\\N{POUND SIGN}'
&gt;&gt;&gt; b'\x92'.decode('latin1').encode('ascii', 'namereplace')
b'\\x92'
&gt;&gt;&gt; ord(b'\x92'.decode('latin1'))
146
</code></pre>

<p>The result decoding b'\xa3' gave me exactly what I was expecting. But the two results for b'\x92' were not what I expected. I was expecting b'\x92'.decode('latin1') to result in U+2018, but it seems to be returning U+0092.</p>

<p>What am I missing?</p>

<blockquote>
  <p>I was expecting b'\x92'.decode('latin1') to result in U+2018</p>
</blockquote>

<p><code>latin1</code> is an alias for <a href="https://en.wikipedia.org/wiki/ISO/IEC_8859-1" rel="nofollow">ISO-8859-1</a>. In that encoding, byte 0x92 maps to character U+0092, an unprintable control character.</p>

<p>The encoding you might have really meant is <code>windows-1252</code>, the Microsoft <a href="https://en.wikipedia.org/wiki/Windows-1252" rel="nofollow">Western code page</a> based on it. In that encoding, 0x92 is U+2019 which is close...</p>

<p>(Further befuddlement arises because for historical reasons web browsers are also confused between the two. When a web page is served as <code>charset=iso-8859-1</code>, web browsers actually use <code>windows-1252</code>.)</p>

python python-3.x unicode python-unicode