RedBencode:
Filter:
Classes (extension) | Red > redTools

RedBencode : Object
ExtensionExtension

Bencode encoder and decoder

Description

Read about this format here... http://en.wikipedia.org/wiki/Bencode

Class Methods

RedBencode.encode(array)

Encodes an array of items as a bencoded string.

Arguments:

array

Expects an Array with items of the following kind...

For example here is a valid argument with different items...

Returns:

A String containing the encoded data. For example...

RedBencode.encodeBytes(array)

Same as *encode but returns an array with 8bit bytes suitable for sending over serial port.

Returns:

An Int8Array containing the encoded data as 8bit bytes. For example...

RedBencode.decodeBytes(array)

Same as *decode but useful when decoding data received from the serial port.

Arguments:

array

An Int8Array with 8bit values.

RedBencode.decodeString(string)

Same as *decode but takes a String as argument. This is the more common method for decoding (compare *decode and *decodeBytes).

Arguments:

string

A bencoded String

RedBencode.decode(stream)

Decodes a bencoded stream of characters in to an array of items (Integer, String, Array, Dictionary). Usually it is easier to use the *decodeString method as it will automatically create a CollStream out of the argument string.

NOTE: Event will become Dictionary and List will become Array.

Arguments:

stream

A CollStream.

Inherited class methods

Instance Methods

Inherited instance methods

Examples