title: JavaScript force UTF-8 encoding
body: <p>I found this article: <a href="http://ecmanaut.blogspot.ro/2006/07/encoding-decoding-utf8-in-javascript.html" rel="nofollow noreferrer">http://ecmanaut.blogspot.ro/2006/07/encoding-decoding-utf8-in-javascript.html</a></p>
  
  <p>And many others that recommended this method. But <code>unescape(encodeURIComponent(srt))</code> doesn't seem to work for me. I'm trying to convert the contents of a file that I get with <code>XMLHttpRequest</code>.</p>
  
  <p>Before using <code>unescape(encodeURIComponent(srt))</code> the unicode characters show as "?", after the conversion, all unicode characters show as "ï¿½". So I'm to assume that the conversion failed.</p>
  
  <p>The file itself is encoded with ANSI.</p>
  
  <p>Here's the Fiddle: <a href="http://jsfiddle.net/9g6zkmof/1/" rel="nofollow noreferrer">http://jsfiddle.net/9g6zkmof/1/</a></p>
  
  <p>I need this to work in pure javascript.</p>
  
  <p><strong>If you are having the same issue with subtitles from OpenSubtitles, please read <a href="https://stackoverflow.com/questions/28293926/javascript-force-utf-8-encoding/28298390#28298390">this answer</a>.</strong> Otherwise, the selected answer is the correct one.</p>
  
  <p>Thanks</p>