readBenc: Read content encoded in Bencoding

Description Usage Arguments Details Value Note Author(s) Examples

View source: R/read.R

Description

readBenc reads content in Bencoding into R objects.

Usage

1
readBenc(what)

Arguments

what

character string of file name(s), binary connection or a raw vector

Details

Bencoding defines integers, strings, lists and dictionaries which are stored as integer (or real) scalars, string scalars, pairlists and named parilists respectively.

Value

Decoded content. If what is a character vector of more than one element then the result is a list equivalent to lapply(what, readBenc).

Note

In principle Bencoding supports integers of arbitary precision, but R only supports signed integers up to 32-bit. All values outsisde that range will be stored as (double-precision) reals. This means that only signed integers up to 53-bit precision will be represented without loss of precision.

R does not allow strings with embedded NULs, so any string with a value less than TAB is returned as a raw vector.

Author(s)

Simon Urbanek

Examples

1
2
  ex <- charToRaw("d1:ai100e1:bl3:fooi123456789012345e3:baree")
  readBenc(ex)

s-u/bencoding documentation built on May 28, 2019, 10:47 a.m.