In all snippets below,
  1. the 1st half of the pipe is slurping the file, decoding of BitTorrent bencode serialisation format and printing the torrent name
  2. the 2nd half of the pipe is echoing STDIN to STDOUT
perl -MBencode=bdecode -gnE \ 'say $_->{info}{name} for bdecode $_' \ ~/.local/share/qBittorrent/BT_backup/1f1c7bab36973365cbe6572b09e0926 +abaad31a6.torrent \ | perl -pe ''

the output is:

Crysis�

(I've put the output as a paragraph, not as code, coz it doesn't display properly as code)

I need unicode support, so add -Mutf8::all, and it fails:

perl -MBencode=bdecode -gnE \ 'say $_->{info}{name} for bdecode $_' \ ~/.local/share/qBittorrent/BT_backup/1f1c7bab36973365cbe6572b09e0926 +abaad31a6.torrent \ | perl -Mutf8::all -pe '' Can't decode ill-formed UTF-8 octet sequence <AE>.
Even Raku/Perl6 fails:
perl -MBencode=bdecode -gnE \ 'say $_->{info}{name} for bdecode $_' \ ~/.local/share/qBittorrent/BT_backup/1f1c7bab36973365cbe6572b09e0926 +abaad31a6.torrent \ | raku -e '$*IN.slurp.put' Malformed UTF-8 near bytes 69 73 ae in block <unit> at -e line 1
Raku needs adjustments:
perl -MBencode=bdecode -gnE \ 'say $_->{info}{name} for bdecode $_' \ ~/.local/share/qBittorrent/BT_backup/1f1c7bab36973365cbe6572b09e0926 +abaad31a6.torrent \ | raku -e '$*IN.slurp(:bin).decode("utf8-c8").put'

the output is:

Crysis􏿽xAE

The torrent name in the qBittorent is shown as Crysis®

The torrent file (inside a .tgz archive):

https://github.com/user-attachments/files/16258067/1f1c7bab36973365cbe6572b09e0926abaad31a6.torrent.tgz

(part of Raku issue over there https://github.com/rakudo/rakudo/issues/5606. perlmonks doesn't support uploading files?)

The main issue is the whole thing dies instead of carrying on. I would expect a warning about a malformed string, not a fatal error.


In reply to Can't decode ill-formed UTF-8 octet sequence by Veraellyunjie

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.