title: detect response body encoding with nodejs
body: <p>I am writing a spider with jsdom and jQuery like <a href="https://github.com/tmpvar/jsdom/blob/master/README.md" rel="nofollow noreferrer">the example</a></p>
  
  <p>There's just one problem: When the web page is not UTF-8 encoded and response header's content-type does not tell me the charset, how do I detect the encoding of the response body?</p>
  
  <p>I know node-iconv can help, but the problem is I need to know the encoding first</p>
  
  <p>(Bonus question: How does web browsers auto detect the encoding of a web page?)</p>