From: Farrel Lifson Date: 2006-12-07T19:04:28+09:00 Subject: Re: How to unpack unusual binary structure? On 07/12/06, Leo -- wrote: > Hello everyone > > I try to read binary file and it has section in following format: > (I suspect this comes from .h file) > > ... > then the bars array (one-byte justification) follows > > pragma pack(push,1) > //---- Standard representation of a quote in the base > struct RateInfo { > time_t ctm; // current time in seconds > double open; > double low; > double high; > double close; > double vol; > }; > pragma pack(pop) > ... > > I don't know what to do with pragma pack. I googled and found that this > is some weird bit-level alignment for records. But I can't figure out, > how do I read and .unpack such records. > > Can I just do .read(4 + 5 * 8) and get a record? > How do I decode it if its packed with this pragma pack? > > Need help... > > -- > Posted via http://www.ruby-forum.com/. > > Have you looked at String#unpack ? Farrel