title: Converting byte array to string in javascript
body: <p>How do I convert a byte array into a string?</p>
  
  <p>I have found these functions that do the reverse:</p>
  
  <pre><code>function string2Bin(s) {
      var b = new Array();
      var last = s.length;
  
      for (var i = 0; i &lt; last; i++) {
          var d = s.charCodeAt(i);
          if (d &lt; 128)
              b[i] = dec2Bin(d);
          else {
              var c = s.charAt(i);
              alert(c + ' is NOT an ASCII character');
              b[i] = -1;
          }
      }
      return b;
  }
  
  function dec2Bin(d) {
      var b = '';
  
      for (var i = 0; i &lt; 8; i++) {
          b = (d%2) + b;
          d = Math.floor(d/2);
      }
  
      return b;
  }
  </code></pre>
  
  <p>But how do I get the functions working the other way?</p>
  
  <p>Thanks.</p>
  
  <p>Shao</p>