Talk:Bencode

message: The examples of bencoding given are much, much less helpful than they should be as they are not accompanied by an explanation of how the process operates, which is far from self-evident from the examples. It's similar to having a page entitled "foocoding" and having an example saying "the foocoded form of bar is baz, and the foocoded form of quux is xyzzy". Not very helpful without an explanation of how the clear text and cyphertext relate to each other.Thisisnotme 12:37, 12 July 2006 (UTC)
replies: text: I expanded the article by describing how it works (as well as adding some explanations, a few of its properties, and making a few corrections). I retained most of the examples. 130.89.167.52 21:25, 14 July 2006 (UTC)
thread_title:  How does bencoding actually work? 

message: "While not particularly efficient, bencoding is simple"
Not efficient compared to what?  Certainly not XML, at least.  I guess only byte-encoding the string lengths would gain you anything (notwithstanding some sort of compression)?  — Christopher (talk) @ 23:13, 20 July 2006 (UTC)
replies: text: You're right. Wording changed, comparing bencode to a pure binary encoding. --Kwi | Talk 23:26, 23 July 2006 (UTC)
thread_title:  Efficiency 

message: I've removed a fragment in the the Encoding algorithm section stating that Bencoding "is defined recursively."  In actuality there is nothing recursive about Bencode's definition.  And while bencoded dictionaries allow composition (a dictionary may contain another dictionary),  recursion is not possible (a dictionary cannot contain itself.) — Foorider (talk) 01:00, 14 February 2008 (UTC)
replies: text: I think you're splitting hairs. A bencode implementation is highly likely to implement encoding and decoding recursively. Schwatoo (talk) 01:41, 6 March 2008 (UTC)
replies: text: That doesn't mean it's recursive. It's trivial to write a loop decoder using a data stack instead. 91.16.24.48 (talk) 17:52, 19 February 2011 (UTC)
replies: text: Well, it is defined recursively, but neither BEP 3 nor the wiki.theory.org spec bothers to mention this, so we really don't need to either. (Though I also don't see any particular reason not to mention it.) And there's certainly no implication that it should necessarily be implemented that way; it's presumably written that way for brevity/clarity. —SamB (talk) 00:40, 25 January 2015 (UTC)
thread_title:  Recursion 

message: Page fails to mention that dictionary elements should be sorted by key.  In the trivia section it mentions "there is only a single valid bencoding", without ordered dictionaries this wouldn't be possible.
Schwatoo (talk) 01:37, 6 March 2008 (UTC)
replies: text: With "list elements have a certain order" you mean that programming languages usually treat two differently ordered lists as semantically unequal objects, but for a dictionary a programmer usually cannot get a position of an element in a dictionary. With "list elements have a certain order" you do not mean that there is a fixed ordering algorithm for list elements, right? Still Angryjames's question remains, whether bencode mandates such an algortihm to ensure bijection. --Tddt (talk) 00:13, 21 May 2012 (UTC)

text: Ah, wait, I already found an example why such an algorithm cannot exist for lists. For instance the "path" element in the info part in multi file mode: "4:pathl 4:path 2:to 8:file.ext e" relies on an unsorted ordering. So it'd be up to the BEPs etc. of certain list keys to ensure bijection by mandating a certain sorting algoritm if appropriate, right? But again, looking at for instance BEP-19, this does not seem to be the case: It does not mandate a lexicographical ordering of the elements in the 'url-list', which results in multiple valid encodings for the same set of webseeds - without imposing a semantical difference upon differing orderings. Ergo, contrary to what the "Features" section claims bencoding is not really bijective? --Tddt (talk) 00:59, 21 May 2012 (UTC)
thread_title:  Dictionary Sorting 

message: "The specification does not deal with encoding of characters outside the ASCII set; to mitigate this, some BitTorrent applications explicitly communicate the encoding (most commonly UTF-8) in various non-standard ways."
Hmm, sure? BEP-3 says: "All strings in a .torrent file that contains text must be UTF-8 encoded." --Tddt (talk) 23:38, 20 May 2012 (UTC)
replies: text: Bencoding is not only used for the torrent file but may also be used somewhere else (e.g. tracker response). Even in the .torrent file there is a string which is not UTF-8 encoded: The pieces entry in the info dictionary. It contains the SHA1 hashes in binary form (each hash is represented by 20 bytes - not characters) BEP-3. Korexio (talk) 09:35, 11 June 2012 (UTC)
thread_title:  Strings and UTF-8 

message: "When editing torrent files, any changes to the info directory index will change the torrent file infohash."
This is a deficiency specific to torrent files, not Bencode. Therefore the sentence is irrelevant and should be removed.
:And it's not even a defect; the whole point of infohashes is that any difference inside the info dictionary will lead to a different infohash, hence the name. —SamB (talk) 00:44, 25 January 2015 (UTC)
thread_title:  Features & defects