Skip to content

Commit

Permalink
[Units] Handle correct encoding when checking trivia answers
Browse files Browse the repository at this point in the history
  • Loading branch information
Harmon758 committed Oct 1, 2022
1 parent ebe2064 commit 1820f77
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion units/trivia.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def check_answer(answer, response, inflect_engine = None):
if character in response:
response = response.replace(character, "")
# Fix wrong encoding
answer = answer.encode("ISO-8859-1").decode("UTF-8")
with contextlib.suppress(UnicodeDecodeError):
answer = answer.encode("ISO-8859-1").decode("UTF-8")
# Remove diacritics
answer = "".join(
character for character in unicodedata.normalize("NFD", answer)
Expand Down

0 comments on commit 1820f77

Please sign in to comment.