sub byte_align_decode { my $bytes = shift; $bytes ^= "\x80" x length($bytes); unpack("w*", $bytes); } # from the example in the above URL print join(' ', byte_align_decode("\x06\xb8\x85\x0d\x0c\xb1")), "\n"; # emits: 824 5 214577 #### sub byte_align_encode { my $bytes = pack("w*", @_); $bytes ^= "\x80" x length($bytes); }