Changeset 32923 in project


Ignore:
Timestamp:
11/20/15 16:14:32 (5 years ago)
Author:
Caolan McMahon
Message:

Add string->bencode and bencode->string procedures

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/bencode

    r32892 r32923  
    3535Writes Bencoded data to {{port}}, defaults to {{current-output-port}}.
    3636
     37<procedure>(bencode->string data)</procedure>
     38
     39Returns Bencoded string for provided data.
     40
     41<procedure>(string->bencode str)</procedure>
     42
     43Returns Bencode data parsed from provided string.
     44
    3745=== Example
    3846
     
    4048(use bencode)
    4149
    42 (call-with-input-string "l5:helloi42ee" read-bencode)
     50(string->bencode "l5:helloi42ee")
    4351;; => #("hello", 42)
    4452
    45 (with-output-to-string
    46   (lambda ()
    47     (write-bencode '((name . "CHICKEN")))))
    48 
     53(bencode->string '((name . "CHICKEN")))
    4954;; => "d4:name7:CHICKENe"
    5055</enscript>
Note: See TracChangeset for help on using the changeset viewer.