Skip to content

Commit

Permalink
Replace invalid characters even when chardet has found an encoding (#306
Browse files Browse the repository at this point in the history
)

In some cases, it seems to find an encoding that's not valid for the
entire string.
  • Loading branch information
jelmer authored Jan 19, 2023
1 parent 6472d3f commit 3cbab50
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion klaus/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def force_unicode(s):
# Try chardet, if available
encoding = chardet.detect(s)["encoding"]
if encoding is not None:
return s.decode(encoding)
return s.decode(encoding, 'replace')

return s.decode('latin1', 'replace')

Expand Down

0 comments on commit 3cbab50

Please sign in to comment.