title: How to convert character encoding from CP932 to UTF-8 in nodejs javascript, using the nodejs-iconv module (or other solution)
body: <p>I'm attempting to convert a string from CP932 (aka Windows-31J) to utf8 in javascript.  Basically I'm crawling a site that ignores the utf-8 request in the request header and returns cp932 encoded text (even though the html metatag indicates that the page is shift_jis).</p>
  
  <p>Anyway, I have the entire page stored in a string variable called "html".  From there I'm attempting to convert it to utf8 using this code:</p>
  
  <pre><code>var Iconv = require('iconv').Iconv;
  var conv = new Iconv('CP932', 'UTF-8//TRANSLIT//IGNORE');
  
  var myBuffer = new Buffer(html.length * 3);
  myBuffer.write(html, 0, 'utf8')
  var utf8html = (conv.convert(myBuffer)).toString('utf8');
  </code></pre>
  
  <p>The result is not what it's supposed to be.  For example, the string: "投稿者さんの 稚内全日空ホテル のクチコミ (感想・情報)" comes out as "ｿｽｿｽｿｽeｿｽﾒゑｿｽｿｽｿｽｿｽｿｽ ｿｽtｿｽｿｽｿｽSｿｽｿｽｿｽｿｽｿｽzｿｽeｿｽｿｽ ｿｽﾌクｿｽ`ｿｽRｿｽ~ (ｿｽｿｽｿｽzｿｽEｿｽｿｽｿｽｿｽ)"</p>
  
  <p>If I remove //TRANSLIT//IGNORE (Which should cause it to return similar characters for missing characters, and failing that omit non-transcode-able characters), I get this error:
  Error: EILSEQ, Illegal character sequence.</p>
  
  <p>I'm open to using any solution that can be implemented in nodejs, but my search results haven't yielded many options outside of the nodejs-iconv module.</p>
  
  <p>nodejs-iconv ref: <a href="https://github.com/bnoordhuis/node-iconv" rel="nofollow">https://github.com/bnoordhuis/node-iconv</a></p>
  
  <p>Thanks!</p>
  
  <p>Edit 24.06.2011:
  I've gone ahead and implemented a solution in Java.  However I'd still be interested in a javascript solution to this problem if somebody can solve it.</p>