title: Convert UTF-8 as string of binary 0 and 1s to code point
body: <p>If you have a string of bits, how do you convert that into the correct code point if that string of <code>0</code>s and <code>1</code>s is in utf-8 encoding.</p>
  <p>For example:</p>
  <pre><code>accented_a_part1 = &quot;100001&quot;
  accented_a_part2 = &quot;00011&quot;
  
  accented_a_int = int(accented_a_part2 + accented_a_part1, 2)
  print(accented_a_int),          # =&gt; 225
  print(unichr(accented_a_int))   # =&gt; á    http://www.unicode.org/charts/PDF/U0080.pdf
  
  accented_a_in_utf8 = &quot;110&quot; + accented_a_part2 + &quot;10&quot; + accented_a_part1
  accented_a_in_utf8_as_raw_int = int(accented_a_in_utf8, 2)
  print(accented_a_in_utf8_as_raw_int),        # =&gt; 50081 (not the codepoint you want)
  print(unichr(accented_a_in_utf8_as_raw_int)) # =&gt; 쎡    (and therefore not the character you want)
  </code></pre>
  <p><a href="https://www.rfc-editor.org/rfc/rfc3629#page-4" rel="nofollow noreferrer" title="UTF-8 specification">UTF-8 specification</a></p>