# Fix a torrent file encoding

Published on

Sometimes, when you open a torrent file, the non-Latin letters in the file names will appear garbled. Apparently, some programs write the utf-8 name in the field path.utf-8 and write the field path in some other encoding.

I wrote a small Perl script that fixes such torrent files by copying the path.utf-8 field into the path field. To fix the torrent file:

1. Make sure you have Perl installed.

2. Install the Bencode Perl module.

E.g. on Fedora, you can run dnf install perl-Bencode.noarch.

3. Run

perl fix-torrent-encoding.pl my_broken_file.torrent new_fixed_file.torrent

and new_fixed_file.torrent will be created.