Python struct.unpack in delphi -


how use built in python function named: struct.unpack in delphi python do. here example:

x = struct.unpack(">h",data[offset:offset+2])[0] 

>h big endian unsigned 2 byte value.

in delphi this:

var   x: word;   data: tbytes; .... x := ntohs(pword(@data[offset])^); 

let's @ in more detail:

  • data array of bytes , data[offset] value trying unpack.
  • ntohs converts network byte order (big endian) host byte order.
  • since parameter of ntohs word, need treat data[offset] word , hence cast.

in order call ntohs you'll need use winsock unit.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -