String handling adjustments

This commit is contained in:
Paul Warren 2024-10-12 20:36:55 +11:00
parent 3929da604d
commit 6d3a9d5380

View file

@ -30,17 +30,23 @@ class DataType():
# helper functions for DataType constructors
def decode_string8(decoder):
return str(decoder.decode_string(8).decode('utf-8'))
try:
return str(decoder.decode_string(8).decode('utf-8'))
except UnicodeDecodeError:
return decoder.decode_string(8)
def decode_string16(decoder):
try:
return str(decoder.decode_string(16).decode('utf-8'))
except UnicodeDecodeError:
return str(decoder.decode_string(16))
return decoder.decode_string(16)
def decode_string32(decoder):
return str(decoder.decode_string(32).decode('utf-8'))
try:
return str(decoder.decode_string(32).decode('utf-8'))
except UnicodeDecodeError:
return decoder.decode_string(32)
def encode_16bit_int(encoder, value):
return encoder.add_16bit_int(int(value))