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:
dataarray of bytes ,data[offset]value trying unpack.ntohsconverts network byte order (big endian) host byte order.- since parameter of
ntohsword, need treatdata[offset]word , hence cast.
in order call ntohs you'll need use winsock unit.
Comments
Post a Comment