Skip to content

Commit

Permalink
More flexible encoding fix
Browse files Browse the repository at this point in the history
Fix the encoding of the webrequest data if it is not utf-8 - for whatever reason. Do not assume any encoding but do probe it.
  • Loading branch information
percidae committed Mar 28, 2022
1 parent 95428a3 commit 570fafb
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ def fetch_ics(self, url):
)
)

# Parse ics file, fix broken encoding
if r.encoding=="ISO-8859-1":
dates = self._ics.convert(r.text.encode("latin_1").decode("utf-8"))
# Parse ics file, fix broken encoding dynamically - if necessary
if r.encoding!="uf-8":
dates = self._ics.convert(r.text.encode(r.encoding).decode("utf-8"))
else:
dates = self._ics.convert(r.text)

Expand Down

0 comments on commit 570fafb

Please sign in to comment.