""" I wrote this script to illustrate the problem:
'\x1a' hex string gets truncated when read from file
Does anyone know a workaround?
"""
import struct
x = struct.pack('chhh','a', 6668,22,33)
# x is now 'a\x00\x0c\x1a\x16\x00!\x00'
# just to prove that it is working:
print...