I think the result is correct, so whats the matter with that added half-byte in step 4? Sorry to be stubborn...
Nothing if your code can add 5 bits to an input that contains 8-bit values and you can handle the subsequent conversions and data interpretation.But programmatically speaking, when our input is an octet string, anything added is also an octet (8 bit). So you should postpone adding the 5-bit version to when your octet string is converted to 5-bit array.
Hm, I think we're talking past each other... but I don't know how to express myself better...
Step 4 and step 6 are executed in the OP example, the result is correct. You are telling me that step 4 is wrong or should only be done at step 6. Then the result in OP should also be wrong, because there an 0 (halfbyte) is appended in step 4 (in addition to the added version byte in step 6)...
Can anyone else help? Probably nobody else at home here...
Thank you for your efforts pooya87