unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: maillaxa@gmail.com
Subject: Re: Read binary and pack/unpack functions ?
Date: 21 Nov 2006 21:33:14 -0800	[thread overview]
Message-ID: <1164173594.063442.170800@e3g2000cwe.googlegroups.com> (raw)
In-Reply-To: <mailman.965.1164153409.2155.help-gnu-emacs@gnu.org>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 1254 bytes --]


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 ?

Regards,

Xavier

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)
   (save-excursion
     (set-buffer (create-file-buffer file-name))
     (erase-buffer)
     (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))))

  parent reply	other threads:[~2006-11-22  5:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-21 22:46 Read binary and pack/unpack functions ? Xavier Maillard
2006-11-21 23:55 ` Kevin Rodgers
     [not found] ` <mailman.965.1164153409.2155.help-gnu-emacs@gnu.org>
2006-11-22  5:33   ` maillaxa [this message]
2006-11-22  6:50 ` Magnus Henoch
     [not found] ` <mailman.974.1164178530.2155.help-gnu-emacs@gnu.org>
2006-11-22 13:20   ` Johan Bockgård

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1164173594.063442.170800@e3g2000cwe.googlegroups.com \
    --to=maillaxa@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).