title: UnicodeDecodeError: 'utf8' codec can't decode byte 0x9c
body: <p>I have a socket server that is supposed to receive UTF-8 valid characters from clients.</p>
  <p>The problem is some clients (mainly hackers) are sending all the wrong kind of data over it.</p>
  <p>I can easily distinguish the genuine client, but I am logging to files all the data sent so I can analyze it later.</p>
  <p>Sometimes I get characters like this <code>œ</code> that cause the <code>UnicodeDecodeError</code> error.</p>
  <p>I need to be able to make the string UTF-8 with or without those characters.</p>
  <hr />
  <p><strong>Update:</strong></p>
  <p>For my particular case the socket service was an MTA and thus I only expect to receive ASCII commands such as:</p>
  <pre><code>EHLO example.com
  MAIL FROM: &lt;john.doe@example.com&gt;
  ...
  </code></pre>
  <p>I was logging all of this in JSON.</p>
  <p>Then some folks out there without good intentions decided to send all kind of junk.</p>
  <p>That is why for my specific case it is perfectly OK to strip the non ASCII characters.</p>