0

I have a message where a variable length of 7Bit characters is encoded. Unfortunately those 7Bit characters are stored in the message as 7Bit. That means the last byte of the message is not necessarily aligned to a byte boundary.

Decoding a message with Preon works fine, but when encoding the previously decoded message with Preon and comparing the byte arrays, the arrays do not match in length. The encoded byte array is one byte smaller than the original one.

I debugged Preon because I assumed a bug, but it works as designed. When a byte boundary is reached, Preon stores the remaining bits until the next write() call to the BitChannel occures. But for the last byte there is no further call.

The question is, is there a way to tell Preon to flush the remaining buffer?

Michael Rumpf
  • 371
  • 1
  • 5
  • 9
  • I further analysed the code and came to the conclusion that a flush() operation is missing before the encode() method returns to the caller, writing any remaining bits to the next byte boundary by filling any missing bits with zero. I'm a little bit confused by the different project hosting locations. There is a JIRA on codehaus.org and the GitHub repo also accepts issue reports. I would create a ticket for this on GitHub and submit a patch. – Michael Rumpf Jul 19 '13 at 11:21
  • https://github.com/preon/preon/pull/25 – Michael Rumpf Jul 19 '13 at 11:49

0 Answers0