Skip to content

Commit

Permalink
fix #20; replace invalid unicode chars instead of raising UnicodeDeco…
Browse files Browse the repository at this point in the history
…deError
  • Loading branch information
rossengeorgiev committed Jul 26, 2019
1 parent f5b02ee commit b287bd0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions vdf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,14 @@ def read_string(s, idx, wide=False):
raise SyntaxError("Unterminated cstring, index: %d" % idx)
result = s[idx:end]
if wide:
result = result.decode('utf-16')
result = result.decode('utf-16', 'replace')
elif bytes is not str:
result = result.decode('utf-8')
result = result.decode('utf-8', 'replace')
else:
try:
result.decode('ascii')
except:
result = result.decode('utf-8')
result = result.decode('utf-8', 'replace')
return result, end + (2 if wide else 1)

stack = [mapper()]
Expand Down

0 comments on commit b287bd0

Please sign in to comment.