Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions pyads/ads.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,18 @@ def dict_from_bytes(
if plc_datatype == PLCTYPE_STRING:
if str_len is None:
str_len = PLC_DEFAULT_STRING_SIZE
var_array.append(
bytearray(byte_list[index: (index + (str_len + 1))])
.partition(b"\0")[0]
.decode("utf-8")
)
try:
var_array.append(
bytearray(byte_list[index: (index + (str_len + 1))])
.partition(b"\0")[0]
.decode("utf-8")
)
except:
var_array.append(
bytearray(byte_list[index: (index + (str_len + 1))])
.partition(b"\0")[0]
.decode("cp-1252")
)
index += str_len + 1
elif plc_datatype == PLCTYPE_WSTRING:
if str_len is None: # if no str_len is given use default size
Expand Down