Skip to content

Instantly share code, notes, and snippets.

@NalaGinrut
Created October 20, 2012 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NalaGinrut/3922700 to your computer and use it in GitHub Desktop.
Save NalaGinrut/3922700 to your computer and use it in GitHub Desktop.
binary->string
(use-modules (rnrs))
(define* (binary->string bin #:key (base 16) (endiannes 'little))
(let ((bl (bytevector->uint-list bin endiannes 1))
(n (car (assoc-ref '((2 "~b") (8 "~o") (16 "~x")) base))))
(call-with-output-string
(lambda (port)
(for-each (lambda (i) (format port n i)) bl)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment