]> git.phdru.name Git - extfs.d.git/blobdiff - torrent
Feat(torrent): Try harder to guess encoding
[extfs.d.git] / torrent
diff --git a/torrent b/torrent
index bd5ff13f7db394d4b77329a278afed1f2bbd5ccb..a0f827ef91f7ad213d7ab70445e9ef0e54e6175a 100755 (executable)
--- 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