Created
October 20, 2012 08:41
-
-
Save NalaGinrut/3922700 to your computer and use it in GitHub Desktop.
binary->string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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