From: Francis Cianfrocca Date: 2006-12-08T23:31:45+09:00 Subject: Re: Am I missing something about BER-compressed integer? On 12/8/06, Francis Cianfrocca wrote: > All: > > The following: > > p [9999].pack("w") > > gives: > > "\316\017" > > but I expected to get: > > "\047\017" > > Notice the correct bit pattern for the upper octet (100111) appears in > the octet generated by Ruby (11001110) but shifted and with an extra > bit at the top. Is this a bug in pack("w"), or is my expectation > wrong? > > Thanks, > -f > > I figured it out. There's no bug in Ruby. pack("w") produces the integer representation that's occasionally used in BER to save space when representing things like OIDs, not the "standard" BER representation that requires a field-size prefix.