From 5e3deb43a2b9775a5d4e6b06df27dc8e6a8884c6 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 14 Oct 2023 17:01:59 +0300 Subject: [PATCH] Feat(torrent): Try harder to guess encoding --- torrent | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 -- 2.39.2