From: Oleg Broytman Date: Sat, 14 Oct 2023 14:01:59 +0000 (+0300) Subject: Feat(torrent): Try harder to guess encoding X-Git-Url: https://git.phdru.name/?p=extfs.d.git;a=commitdiff_plain Feat(torrent): Try harder to guess encoding --- diff --git a/torrent b/torrent index bd5ff13..a0f827e 100755 --- a/torrent +++ b/torrent @@ -318,7 +318,12 @@ def decode_torrent(): elif codepage: encoding = codepage.decode('ascii') else: - encoding = 'ascii' + for encoding in ('ascii', 'utf-8', default_encoding): + try: + return decode_dict(torrent, encoding) + except UnicodeDecodeError: + pass + torrent_error('UnicodeDecodeError') return decode_dict(torrent, encoding) return torrent