title: Convert zero-padded bytes to UTF-8 string
body: <p>I'm <a href="http://docs.python.org/dev/library/struct.html#struct.unpack">unpacking</a> several structs that contain <a href="http://docs.python.org/dev/library/struct.html#format-characters"><code>'s'</code></a> type fields from C. The fields contain zero-padded UTF-8 strings handled by <a href="http://linux.die.net/man/3/strncpy"><code>strncpy</code></a> in the C code (note this function's vestigial behaviour). If I decode the bytes I get a unicode string with lots of <code>NUL</code> characters on the end.</p>
  
  <pre><code>&gt;&gt;&gt; b'hiya\0\0\0'.decode('utf8')
  'hiya\x00\x00\x00'
  </code></pre>
  
  <p>I was under the impression that trailing zero bytes were part of UTF-8 and would be dropped automatically.</p>
  
  <p>What's the proper way to drop the zero bytes? </p>