title: Write bytes literal with undefined character to CSV file (Python 3)
body: <p>Using Python 3.4.2, I want to get a part of a website. According to the meta tags, that website is encoded with <code>iso-8859-1</code>. And I want to write one part (along with other parts) to a CSV file.</p>
  
  <p>However, this part contains an undefined character with the hex value <code>0x8b</code>. In order to preserve the part as good as possible, I want to write it <em>as is</em> into the CSV file. However, Python doesn't let me do it.</p>
  
  <p>Here's a minimal example:</p>
  
  <pre><code>import urllib.request
  import urllib.parse
  import csv
  
  if __name__ == "__main__":
      with open("bytewrite.csv", "w", newline="") as csvfile:
          a = b'\x8b' # byte literal by urllib.request
          b = a.decode("iso-8859-1")
  
          w = csv.writer(csvfile)
          w.writerow([b])
  </code></pre>
  
  <p>And this is the output:</p>
  
  <pre class="lang-none prettyprint-override"><code>Traceback (most recent call last):
    File "D:\Eigene\Dateien\Code\Python\writebyte.py", line 12, in &lt;module&gt;
      w.writerow([b])
    File "C:\Python34\lib\encodings\cp1252.py", line 19, in encode
      return codecs.charmap_encode(input,self.errors,encoding_table)[0]
  UnicodeEncodeError: 'charmap' codec can't encode character '\x8b' in position 0: character maps to &lt;undefined&gt;
  </code></pre>
  
  <p>Eventually, I did it manually. It was just copy and paste with Notepad++, and according to a hex editor the value was inserted correctly. But how can I do it with Python 3? Why does Python even care what 0x8b stands for, instead of just writing it to the file?</p>
  
  <p>It further irritates me that according to <code>iso8859_1.py</code> (and also <code>cp1252.py</code>) in <code>C:\Python34\lib\encodings\</code> the lookup table seems to not interfere:</p>
  
  <pre><code># iso8859_1.py
      '\x8b'     #  0x8B -&gt; &lt;control&gt;
  # cp1252.py
      '\u2039'   #  0x8B -&gt; SINGLE LEFT-POINTING ANGLE QUOTATION MARK
  </code></pre>