-
Notifications
You must be signed in to change notification settings - Fork 2
Bencoding
Serialize.NET supports reading and writing Bencoded content using the BencodingObjectReader and BencodingObjectWriter classes, respectively.
-
Integer types are all Bencoded as integers, e.g., the value 1 is encoded as
i1e. -
Byte arrays are Bencoded as binary strings, e.g., 41-42-43 is encoded as
3:abc. -
Strings are encoded as UTF-8 encoded binary strings, e.g., "xyz" is encoded as
3:xyz. -
Floating point values are not explicitly supported by the Bencoding specification. In the spirit of readability that is part of the Bencoding design, floating point values are Bencoded as human-readable strings rather than a typically more compact binary representation, e.g., 1.1 is encoded as
3:1.1. -
Objects are Bencoded as dictionaries, with member keys encoded as strings (as required by the specification).
For example, the following is an encoded object with two members (the string "Bob" and the integer value 1):
d 1:1 3:Bob 1:2 i1e e(whitespace added for readability) -
Arrays are Bencoded as lists, e.g., [1, 2, 3] is encoded as
l i1e i2e i3e e(whitespace added for readability). -
The Bencoding specification does not explicitly support null values, so the Serialize.NET implementation adds the token "n" to represent a null value.
- If a serialized object contains one or more null values, the output will not be compliant with the Bencoding specification, due to the null token extension ("n") that is used by Serialize.NET.
For more information about Bencoding, see http://en.wikipedia.org/wiki/Bencode.