[BitTorrent] Are metainfo files (.torrent) text files ?

Brian Dessent brian at dessent.net
Mon Nov 22 15:05:42 EST 2004

skybuckflying wrote:

> The first line reads:
> "All data in a metainfo file is bencoded"
> This leads me to believe that these files are "text" files.

Bad assumption.  Bencoded strings are 8-bit clean, and the hashes are

> It is unclear to me how these "bytes" need to be encoded.
> It says "raw binary encoded"... what is that ???

What is unclear about that?  It's a raw stream of bytes.  THere is no

> For example suppose I have these 4 bytes
> 255, 127, 64, 8.
> How would I have to encoded them into this big string.

They are not encoded.  The byte values are included directly as binary.

> One last possibility is that metainfo files are not text files.
> Only the first part is "text" and then the pieces section is binary ?
> If that's the case then this line isn't true ofcourse:
> "All data in a metainfo file is bencoded""
> Then this would have to be changed to
> "All data in a metainfo file is bencoded, except the pieces
> section ;)"

False.  There is nothing that says that a bencoded value has to be
"text" (7-bit ascii.)  A bencoded string containing arbitrary binary is
perfectly valid.  If this doesn't make sense to you or you have a
problem writing code to handle it then maybe you should put down the
editor and work on something else.

Do not confuse this with the dicussion about the code page / encoding
used to represent filenames, that's a different issue.  And no, there is
no "Standard" here either -- Bram has said in no uncertain terms that
all filenames must contain regular 7-bit ascii and anyone who wants to
trafer a file with localized names should just suck it.  So clients that
use cp1252 or UTF-8 have just made up extensions to deal with it, but
there is no official way to handle this.


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!

Yahoo! Groups Links

<*> To visit your group on the web, go to:

<*> To unsubscribe from this group, send an email to:
    BitTorrent-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:

More information about the BitTorrent mailing list