Thanks for the suggestion. There is a bug in your approach, though.  The following example will be treated like there is a null byte, but there actually isn't:

"10014141".rjust(8, '0') =~ /00/

Because 1001 is "10 01", there's no null byte.