title: Convert ISO/Windows charsets to UTF-8 in Javascript
body: <p>I'm developing a firefox plugin and i fetch web pages to do some analysis for the user. The problem is when i try to get (XMLHttpRequest) pages that are not utf-8 encoded the string i see is messed up. For example hebrew pages with windows-1125 or Chinese pages with gb2312. </p>
  
  <p>I already tried the following:</p>
  
  <pre><code>var uDecoder=Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].getService(Components.interfaces.nsIScriptableUnicodeConverter);
  uDecoder.charset="windows-1255";
  alert( xhr.responseText );
  
  var decoder=Components.classes["@mozilla.org/intl/utf8converterservice;1"].getService(Components.interfaces.nsIUTF8ConverterService);
  
  alert(decoder.convertStringToUTF8(xhr.responseText,"WINDOWS-1255",true)); 
  </code></pre>
  
  <p>I also tried <code>escape/unescape/encodeURIComponent</code></p>
  
  <p>any ideas???</p>