String handling adjustments
This commit is contained in:
parent
3929da604d
commit
6d3a9d5380
1 changed files with 10 additions and 4 deletions
|
@ -30,16 +30,22 @@ class DataType():
|
||||||
|
|
||||||
# helper functions for DataType constructors
|
# helper functions for DataType constructors
|
||||||
def decode_string8(decoder):
|
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):
|
def decode_string16(decoder):
|
||||||
try:
|
try:
|
||||||
return str(decoder.decode_string(16).decode('utf-8'))
|
return str(decoder.decode_string(16).decode('utf-8'))
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
return str(decoder.decode_string(16))
|
return decoder.decode_string(16)
|
||||||
|
|
||||||
def decode_string32(decoder):
|
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):
|
def encode_16bit_int(encoder, value):
|
||||||
return encoder.add_16bit_int(int(value))
|
return encoder.add_16bit_int(int(value))
|
||||||
|
|
Loading…
Reference in a new issue