title: How to convert a string of bits to byte array
body: <p>I have a string representing bits, such as:</p>
  
  <pre><code>"0000101000010000"
  </code></pre>
  
  <p>I want to convert it to get an array of bytes such as:</p>
  
  <pre><code>{0x0A, 0x10}
  </code></pre>
  
  <p>The number of bytes is variable but there will always be padding to form 8 bits per byte (so 1010 becomes 000010101).</p>