Skip to content

Commit

Permalink
Fix byte order for negative values
Browse files Browse the repository at this point in the history
  • Loading branch information
nmantani committed Dec 14, 2024
1 parent 94fd4ed commit 3c364df
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions plugins/Operations/Encoding/encoding_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,18 +548,26 @@ def decimal_text_to_binary_data(fi):
else:
print("Error: the value %d is out of range for 64 bit integer." % v)
return

if endianness == "Big":
b = list(b)
b.reverse()
converted += "".join(b)
else:
converted += b
else:
h = "%x" % v
if len(h) % 2 == 1:
h = "0" + h

b = binascii.a2b_hex(h)
if endianness == "Little":
b = list(b)
b.reverse()
converted += "".join(b)
else:
converted += b

if endianness == "Little":
b = list(b)
b.reverse()
converted += "".join(b)
else:
converted += b

newdata = orig[:offset] + converted + orig[offset + length:]

Expand Down

0 comments on commit 3c364df

Please sign in to comment.