[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Read binary and pack/unpack functions ?

From: maillaxa
Subject: Re: Read binary and pack/unpack functions ?
Date: 21 Nov 2006 21:33:14 -0800
User-agent: G2/1.0

Kevin Rodgers a écrit :

> Xavier Maillard wrote:
> > Where iactually fail is at reading binary data from the file and
> > packing binary data into a more "neutral" format based on sexp.
> >
> > Do you know any pack/unpack-like functions for GNU Emacs ?
> Are you familiar with Emacs coding systems?

Yes I do and the problem is not with reading binary data but with
"mapping" bytes into something that reflect the binary file format
(header, data, ...).

In perl you have two valuable functions called pack and unpack that
takes a string and expands it out into a list of values. This is what I
am looking for in emacs lisp.

So is there anything similar ?



P.S: here is what I am ending up for reading (temporary and subject to
change. It basically load a file and try to read the first 72 bytes
from there (corresponding to the file header)

  (defun load-memodb (file-name)
     (set-buffer (create-file-buffer file-name))
     (if (fboundp 'set-buffer-multibyte)
         (set-buffer-multibyte t))

     (let ((coding-system-for-read 'binary))
       (insert-file-contents file-name))
     (goto-char (point-min))
     (setq header (memo-read-bytes 72))))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]