title: Convert Windows-1252 subtitle file to utf-8
body: <p>I am downloading Serbian/Bosnian/Croatian subtitles via VLC player on an Ubuntu machine, and have constantly to manually change characters such as æ, è, and ð into ć, č, and đ so that the player can render them properly. I wanted to make a python3 function that can do that for me, but I got lost tyring to understand string encoding and decoding.</p>
  
  <p>Through <code>chardata.detect</code> I found that the encoding of <code>.srt</code> files that VLC player downloads is Windows-1252. So right now, I do something like this:</p>
  
  <pre><code>import codecs
  
  f = codecs.open('my_file.srt', 'r', encoding='Windows-1252')
  data = f.read()
  data_utf8 = data.encode('utf-8')
  f.close()
  </code></pre>
  
  <p>The thing is, when I print to terminal the content of the <code>data</code> varible, I might get a fragment like this:
  <code>obožavam vaše</code>.
  But, when I print to terminal the content of the <code>data-utf8</code> variable, that same fragment now looks like this: 
  <code>obo\xc5\xbeavam va\xc5\xa1e</code>.
  This is not what I expected.</p>
  
  <p>Furthermore, when I now want to save this data to a file</p>
  
  <pre><code>with open('my_utf8_file.srt', 'w') as f:
      f.write(data_utf8)
  </code></pre>
  
  <p>I get <code>TypeError: write() argument must be str, not bytes</code>. </p>
  
  <p>Can anyone tell me what am I doing wrong?</p>