Search code examples
zlibdeflate

zlib format : beginning 2 bytes


I read https://www.ietf.org/rfc/rfc1950.txt. Still I have some doubts. It's mentioned that the CINFO value can't be more than 7, but in one of my inputs to the zlib inflate() function I have 0x68de as the first two bytes. I am getting uncompressed data without any error from zlib. Here 0x68's first four bits are 0110, second four bits are 1000, which means CINFO is 8. I think I am missing something here. Can anyone explain me about these beginning two bytes (0x68de) clearly.


Solution

  • No, for 0x68, CINFO is 6 and CM is 8. CM is bits 0 to 3, which are the low four bits, and CINFO is bits 4 to 7, which are the high four bits. Section 2.1 clearly describes the notation used in the document, and which bits are which.