title: Why I get messy code by using utf-8?
body: <p>I was crawling a website which set its charset as utf-8.But when I was crawling it returned the messy code while my code works when I crawled other website which also uses utf-8 .What is wrong with it?
  Here is my code.</p>
  
  <pre><code>var http = require("http");
  var iconv = require('iconv-lite');
  var url = "http://www.zhihu.com";
  
  //var url = "http://www.renren.com";
  //var url = "http://www.baidu.com";
  
  function download(url, callback) {
      http.get(url, function(res) {
          var data = "";
          res.on('data', function (chunk) {
              data += chunk;
          });
          res.on("end", function() {
              callback(data);
          });
      }).on("error", function() {
          callback(null);
      });
  }
  
  
  download(url, function(data) {
      if (data) {
          console.log(data);
      }
      else console.log("error");  
  });
  </code></pre>
  
  <p>What I expected to get is here.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="zh-CN"&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;meta name="apple-itunes-app" content="app-id=432274380"&gt;
  &lt;meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /&gt;
  &lt;meta name="renderer" content="webkit" /&gt;
  &lt;meta name="description" content="一个真实的网络问答社区，帮助你寻找答案，分享知识。"/&gt;
  &lt;meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/&gt;
  &lt;title&gt;知乎 - 与世界分享你的知识、经验和见解&lt;/title&gt;
  &lt;link rel="apple-touch-icon-precomposed" href="http://static.zhihu.com/static/img/ios/zhihu(57px).png" /&gt;
  &lt;link rel="apple-touch-icon-precomposed" href="http://static.zhihu.com/static/img/ios/zhihu(72px).png" sizes="72x72" /&gt;
  &lt;link rel="apple-touch-icon-precomposed" href="http://static.zhihu.com/static/img/ios/zhihu(76px).png" sizes="76x76" /&gt;
  &lt;link rel="apple-touch-icon-precomposed" href="http://static.zhihu.com/static/img/ios/zhihu(114px).png" sizes="114x114" /&gt;
  &lt;link rel="apple-touch-icon-precomposed" href="http://static.zhihu.com/static/img/ios/zhihu(120px).png" sizes="120x120" /&gt;
  &lt;link rel="apple-touch-icon-precomposed" href="http://static.zhihu.com/static/img/ios/zhihu(152px).png" sizes="152x152" /&gt;
  
  &lt;link rel="shortcut icon" href="http://static.zhihu.com/static/favicon.ico" type="image/x-icon" /&gt;
  &lt;link rel="dns-prefetch" href="p1.zhimg.com"/&gt;
  &lt;link rel="dns-prefetch" href="p2.zhimg.com"/&gt;
  &lt;link rel="dns-prefetch" href="p3.zhimg.com"/&gt;
  &lt;link rel="dns-prefetch" href="p4.zhimg.com"/&gt;
  &lt;link rel="dns-prefetch" href="comet.zhihu.com"/&gt;
  &lt;link rel="dns-prefetch" href="static.zhihu.com"/&gt;
  &lt;link rel="dns-prefetch" href="upload.zhihu.com"/&gt;
  
  &lt;link rel="stylesheet" href="http://static.zhihu.com/static/ver/21cf1daf74b402877d664d7f82658789.reg.css" type="text/css" media="screen,print" /&gt;
  
  &lt;meta name="google-site-verification" content="FTeR0c8arOPKh8c5DYh_9uu98_zJbaWw53J-Sch9MTg" /&gt;
  &lt;meta property="qc:admins" content="14414345146201056375" /&gt;
  &lt;meta name="baidu-site-verification" content="KPFppAFoYF4Kkdv9" /&gt;
  
  &lt;link rel="canonical" href="http://www.zhihu.com" /&gt;
  
  &lt;meta id="znonce" name="znonce" content="b08b4ee57cd14fa39fcb08bd4f1c0673"&gt;
  &lt;!--[if lt IE 9]&gt;
  &lt;script src="http://static.zhihu.com/static/components/respond/dest/respond.min.js"&gt;&lt;/script&gt;
  &lt;link href="http://static.zhihu.com/static/components/respond/cross-domain/respond-proxy.html" id="respond-proxy" rel="respond-proxy" /&gt;
  &lt;link href="/static/components/respond/cross-domain/respond.proxy.gif" id="respond-redirect" rel="respond-redirect" /&gt;
  &lt;script src="/static/components/respond/cross-domain/respond.proxy.js"&gt;&lt;/script&gt;
  &lt;![endif]--&gt;
  
  &lt;script src="http://static.zhihu.com/static/ver/7ef789dcffd76ea3db4d1562e267ff99.instant.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body class="zhi"&gt;
  
  
  
  &lt;div class="wrapper index-content-wrapper"&gt;
  &lt;div class="top"&gt;
  &lt;div class="inner-wrapper"&gt;
  &lt;div class="form-wrapper" id="js-form-wrapper"&gt;
  &lt;div class="logo"&gt;&lt;/div&gt;
  
  &lt;div id="js-sign-flow" class="desk-front sign-flow clearfix"&gt;
  &lt;div class="view view-signin "&gt;
  &lt;form method="post" action="/login" class="zu-side-login-box"&gt;
  &lt;input type="hidden" name="_xsrf" value="0314c2fba8983a24e78e23d48647a8de"/&gt;
  &lt;div class="title clearfix"&gt;
  &lt;a class="js-signup signup-switch with-icon" href="#signup"&gt;注册&lt;i class="icon-sign icon-sign-arrow"&gt;&lt;/i&gt;&lt;/a&gt;
  &lt;a class="with-icon return"&gt;
  &lt;i class="icon-sign icon-sign-arrow-l"&gt;&lt;/i&gt;&lt;span class="js-title-label"&gt;登录知乎&lt;/span&gt;
  &lt;/a&gt;
  &lt;/div&gt;
  &lt;div class="email input-wrapper"&gt;
  &lt;input required type="email" name="email" placeholder="知乎注册邮箱"
  
  &gt;
  &lt;/div&gt;
  &lt;div class="input-wrapper"&gt;
  &lt;input required type="password" name="password" maxlength="128" placeholder="密码"&gt;
  &lt;/div&gt;
  &lt;div class="captcha-holder"&gt;
  
  &lt;/div&gt;
  
  &lt;div class="button-wrapper command"&gt;
  &lt;button class="sign-button" type="submit"&gt;登录&lt;/button&gt;
  &lt;/div&gt;
  &lt;div class="signin-misc-wrapper clearfix"&gt;
  &lt;label class="remember-me"&gt;
  &lt;input type="checkbox" name="rememberme" checked value="y"&gt; 记住我
  &lt;/label&gt;
  &lt;a class="js-resetpassword reset-password" href="#"&gt;忘记密码?&lt;/a&gt;
  &lt;/div&gt;
  &lt;div class="weibo-signup-wrapper"&gt;
  社交帐号直接登录 &amp;nbsp;
  &lt;a class="js-bindweibo" href="javascript:;"&gt;&lt;i class="icon-sign icon-sign-sina"&gt;&lt;/i&gt;&lt;/a&gt;
  &lt;a class="js-bindqq" href="javascript:;"&gt;&lt;i class="icon-sign icon-sign-qq"&gt;&lt;/i&gt;&lt;/a&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>However Here is the messy code it returned.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>� �ZHU��[�s�ƕ���F�R�*����En9�U�8N��{x].V�ј��F �����rb]�Hi#ŶL[�c�PlJ��C�rU��h03��a_�!shf$�~�e�3D���~���n4����_��ƛ'^a*Q՝?r�~1.��s��
  ���Y�F�_U!WP�h��G6���fU��j5�pNT�H���`ߋ�%�8ǚ�%Q�dI��#+QT�ȩ��4����/q/����%�᯾2G�2����N˔zYĳH@�ܘeb.:Q_O��8pj��{�΍���Ν�֍x����߶�������n}s����x}����xg;��Uc�f|w�y�!�j�:O�ϟm���u�v���Gk���KY��A��VI���Ĝ��fٱ�ʜE�L��b�q&lt;'r��t�g���V�j�zؔ0���%�0��_7�i�l4v~ߺ�M&amp;L%ʦw���ypg=����g�_��X)}���x�L@܎#��+���j�`?$�Tbϱ�nGK�0[����R��&gt;YCɩ�K�����h���ּrj���I��B�4 �XM\����W�㫮h�s�+r�14����g-�}�E~��?k���д �&lt;�����C���FK��,|�L�Z� v��LJ+\J�W&lt;��D6�p�á&amp;P��2%ˎ�]���4Ywy��ЋD�ZcDQ�c��\Y�Cz���$��i�%�Dۂ�lM6e^�5�RU��l]T]Ӎـ�°cՈ�D���J,W���ǋ2W�!y����ȡ�9��Q!�����:
  ~qⵊ����YY0�uC_8�S���"���5���Q�e�Z��H�α��QdU/��dY�%YdU�^Q%M�Kk&amp;r��ȩ�v�x���q����k�֒�*y��܂Ɨ��sv�i:{�`H��,:W]�&amp;��2!��-A��dؘ6Y�-`^�$Z��qo96�F̫�0��Вfh&amp;�͞����R@B��*A��:���ٓ!;���8�X&gt;5�8�0�,��������ډM���Φ�-��z'2!�ٔcٱ{�ƀ�Q��as�������[P}9��G]c�јՈ
  �ia۶4� �2eKPT���fۆ1�!/d�RV�����`�!-[p*�9f9K��� r ����
  �y'��R����Z���&lt;������ڽ���d��4��w��Oe���l�٠�){����l�/8�"g0[�{���J�.�2���q&lt;�ާ� h�*&gt;��t�0�0&lt;L����NS����r���w�$�*+�e��+a ����:\�� c�6�n�e��D�,YWe
  �I�A^ô��unez�ט����PG.����g���~�]?�t�Ez���ǡ  ����Cy~]�0Q=���H�s3ba
  y��'�qP����p/޿�V���Гz,��?�A�2���~� ��#��Iߎ!����0��.���ؔe���w�[�b��v&lt;�5���V���5,G\��a���^�F|�l��v c�j`Uĥ}i��DD�ˬG��� U�Y�bz��/1L����aݬ��/3±Rzw�\�x��N�Y�|31g�s@��jTI1Bp��E9�%iڵJ�!�
  �f��g�������W`N �B ⒨�j&amp;��5�;�PJu����k�8��V�ܰ�m�~�\�7��&gt;�����T]�=3���;�3��a~-�����02jB�C�/#|��4TaT�f&amp;v���@-�B$��BR$V*��u�F���~�ւ�(:50O���  ��4��$���]���Q��_^HY&lt;�^���zf���p7�ԫ3�T�OD�T�0 Z��v�o;u�^���wT�A���(�"�˗���!��0IN�P���N�?T$��ׂSu���Q�!S��]�A�H����G�����^Lu&lt;���a�Kk�!h�sDp.�R�I�h���*x��)���=�v�bJa"
  �������NA��� 'P`
  A&gt; ��`�Q1�N=�F��t k�u��@nH�^�ɲӐ0&gt;�t���3#�J�N
  1١o�7�_N���9{�����������p�R{��!D��pZ��u� �NKv�`�� ��Q���\��7��o^9X;��/�(�t���6XHVg�A� ��cu +�H���&lt;�r��!S=9�Q&gt;٨�m���ֹ�޾{���k�CIj�0�ie���6(�ҙr�Z[�5v.5w�}���70�7/}��Y��LAܩ��U�A+�=vb�=�
  qʕh�����R��=�����nK����ȴ�t���+�! ��"�N�%��sI��������
  &lt;��a���u���˜:���מ&amp;���L~�[%�fK�'��M��]�쓅�8$d fo/�H-�/L��!&amp;BA�&gt;l^0]�-v�,Ո˩��tř��92��K��dM�+]�w��E��ʆ �&lt;o�X�T
  aU�$�D�n�nhE��D��37���A����98�ԥ$��as�:{�Vf���#c Z�}��{�V�K�D yQ0ud(� #��&amp;K�f˲����+�!��������"J�-���4"�v�U3��G&lt;�,"芀�d&amp;o �"��&amp;"�oy�x��+�;J����.K��M�F�pq��UN�H4C�u]�M�PM�4e�l�DǠaY�G��ƕ��Y1�`M#�q�EP7;�eUV'�N�M^EE4-[!D�T�Rx[�$ڢ������(A��k��e �������"+HP,ˀ��~����@�$@T��.�;��+vw�p����o�+�L$�X�'�'�*�+s'��0��z�a]�U�H��(�7����MdK��(�AI������=��ʢ�5���,���hLh�t�pZW����4.&amp;j���� 1Q
  ��:o�V%ޠ����5�TO�9L&amp;U2f�T��|ۺ��q�«6���
  SM_������&gt;�����qcF��eY��O35^t��dp'�
  �������&lt;!�N�l[�1F#�Y�gN�\G (��N3%�w��]'����� � 
  X��H���g��,A��
  [!`������W��+��C� �Dј8v�1�EpNT`y;n옖
  Y���Ď&amp;kP�L6�l�@{��~�ָ�ǪFŦ:E�pc�u���y YMQ��0�=��A���������9�qMcI6/ز�_u��G
  O��&lt;,mV���8�9�$]p
  ��%K(�wўށ�#���p�QX����J�;�Gr��tr�
  �`۞5J���7�n�g?�/]lߺ�ܺqp�{z�49'���m}�ݼy������kW���������֗�@��'0��{�1��s�����O?x�`
  d^c������r����Gk�_���i��:�΃�E��or��S���mɏ�6Q�7hk��j=U'!�A\��}�a��U^�a!���' �jHP�?Z[o�����Mc����/���O���h�R|�^�{�`k�������i��n��Ŀ����(&gt;�n���d����ۙRdX&gt;?�E^T$�PbP��b5�.�S?X����\k����N��f���P&amp;�O4v�ڷ��5�s�ʦ��3���ɪ�ve�5U��B&gt;�����_5���k  ��
  B��������I%��3S���M���OA���[�6���� ��^O�����pC�rIT�y����C����w���{�vf�*o�2b8��sWڟ\�� ԋ�.'���l~�A 2�o.��~���y��q?~�&gt;M�e
  7��&gt;�/�����"�g1��6d3&lt;����,K0�T�}k��rtۆ��S��"/(�r���"&amp;�IOAL,���P$&amp;LML��b2D���D�@L4���^$�g��������0!�P�M�i�!�k�/2�$S8|6z�z�~ݳ"��
  ��bo�m�ZgG|I�Rs� �śWZ���}�h���^|��x�*�ŧ�E#�pk�ۙ��o7G�ں�8&amp;q�7[��f�W�G����̫/�`���1��qE����Jg��i�������_������a/�:OO����p)�I�&lt;�^�{����ՠt���۟6��o��n�tF��J';~�*f��pH՜��cׁ$[��e���v�I'��h4��&lt;+�k��l��g�=zn���;ќ��=y��rνFp2��C���a�$[�d��g�0v�-���~9!��g��s盧�B�%J����L�;3�s����9�Ss,��%Dc�?�w�p@=Xw��a=�=* C�#h��І�pp���E�(ˍ���'4Q�ѷx�$PU�vv���
  0����{]�mI�
  ��� �Hu�n�nς2H�- �AG�'���6e�6��A�T��u(5���Yp���|��l��5��u� b�'�$��i���=K�������`5�Bǿ��l��kw��J晞W,�����~�J�� %��:  </code></pre>
  </div>
  </div>
  </p>
  
  <p>Thank you very much!</p>