[Lazarus] Unpack of PHP

Vincent Snijders vincent.snijders at gmail.com
Mon Feb 4 16:38:59 CET 2013


2013/2/4 silvioprog <silvioprog at gmail.com>:
> 2013/2/4 David Knaack <davidknaack at gmail.com>
>>
>> I may not understand the scope of your question, but could you use the
>> swap function?
>>
>> http://www.freepascal.org/docs-html/rtl/system/swap.html
>>
>> Like so (edited in email, not compile checked):
>>
>> function ReadMWord(AStream: TStream): Word;
>>   var
>>     MW: Word
>>   begin
>>     AStream.Read(MW, SizeOf(Word));
>>     Result := Swap(MW);
>>   end;
>
>
> Perfect! :)
>
> Thank you very much!

Instead of swap, you may use beton, so that it works on big endian cpus too:
http://www.freepascal.org/docs-html/rtl/system/beton.html

Vincent




More information about the Lazarus mailing list