Created
April 1, 2021 21:20
-
-
Save x/f201197f8c1a6255aff822f670371fe1 to your computer and use it in GitHub Desktop.
Unicode decode with abstract
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
message.decode('utf-8') | |
except UnicodeDecodeError as err: | |
abstract = message[max(err.start - 10, 0):min(err.end + 10, len(message))].decode(encoding, 'backslashreplace') | |
logging.error(f"Error decoding as UTF-8: {uuid} Problem Area: '{abstract}' Error: {err}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment